This is a standard result in quantitative finance for vanilla (i.e. European style) options. It can be applied to puts as well as calls (thru put-call-parity).
Expressing the put option price as a function of the risk neutral density $q(S_T)$, it is calculated as:
$$ P(S_t,K)=e^{-r(T-t)}\int_0^{\infty}(K-S_T)^+q(S_T)\mathrm{d}S_T $$
The first derivative of this expression with respect to $K$ is
$$ \begin{align} \frac{\partial P}{\partial K}&=e^{-r(T-T)}\int_{0}^{K}q(S_T)\mathrm{d}S_T\\ &=e^{-r(T-t)}\mathrm{P_Q}\left(S_T\leq K\right) \end{align} $$ with $\mathrm{P_Q}\left(S_T\leq K\right)$ the risk neutral probability the put being in the money. For call options, we get a like result
$$ \begin{align} C(S_t,K)&=e^{-r(T-t)}\int_0^{\infty}(S_T-K)^+q(S_T)\mathrm{d}S_T\\ \frac{\partial C}{\partial K}&=-e^{-r(T-T)}\int_{K}^{\infty}q(S_T)\mathrm{d}S_T\\ &=-e^{-r(T-t)}\left(1-\mathrm{P_Q}\left(S_T\leq K\right)\right)\\ &=-e^{-r(T-t)}\mathrm{P_Q}\left(S_T> K\right) \end{align} $$
with $\mathrm{P_Q}\left(S_T> K\right)$ the probability of the call option ending in the money.
You can also have a look at the standard Black-Scholes option pricing equation:
$$ \begin{align} C_{\mathrm{BS}}(S_t,K)&=S_t\mathrm{N}\left(d_1\right)-Ke^{-r(T-t)}\mathrm{N}\left(d_2\right)\\ \Rightarrow\frac{\partial C_{\mathrm{BS}}}{\partial K}&=-e^{-r(T-t)}\mathrm{N}\left(d_2\right) \end{align} $$ with $\mathrm{N}\left(d_2\right)$ the risk-neutral probability of ending in the money.
The equations iny our post are finite difference approximations to the first order derivatives above, driven by the fact that we can usually observe options prices only at discretely sampled strike prices.
You can, of course, then use second order finite difference approximations to directly approximate the probability density function thru the Breeden-Litzenberger formula.