[proofplan]
We translate the statement from random variables to measures by introducing the law $\mu_X=\mathbb P\circ X^{-1}$ on $(\mathbb R,\mathcal B(\mathbb R))$. The forward implication is exactly the Radon-Nikodym theorem applied to the absolute continuity relation $\mu_X\ll\mathcal L^1$. The reverse implication follows because an integral of a nonnegative measurable function over a Lebesgue-null set is zero. Finally, uniqueness follows by applying the density identity to the sets where two candidate densities differ.
[/proofplan]
[step:Express the distribution of $X$ as a measure on the Borel line]
Let $(\Omega,\mathcal F,\mathbb P)$ be the probability space on which $X$ is defined. Let $\mathcal B(\mathbb R)$ denote the Borel $\sigma$-algebra on $\mathbb R$, and let $\mathcal L^1$ denote one-dimensional Lebesgue measure on $(\mathbb R,\mathcal B(\mathbb R))$. Define the law of $X$ as the pushforward measure
\begin{align*}
\mu_X:\mathcal B(\mathbb R)&\to[0,1] \\
A&\mapsto \mathbb P(X^{-1}(A)).
\end{align*}
Since $X:(\Omega,\mathcal F)\to(\mathbb R,\mathcal B(\mathbb R))$ is measurable, $X^{-1}(A)\in\mathcal F$ for every $A\in\mathcal B(\mathbb R)$, so $\mu_X$ is a probability measure on $(\mathbb R,\mathcal B(\mathbb R))$. For every $A\in\mathcal B(\mathbb R)$, the event $\{X\in A\}$ is $X^{-1}(A)$, hence
\begin{align*}
\mu_X(A)=\mathbb P(X\in A).
\end{align*}
By the definition of absolute continuity for a real-valued random variable, $X$ is absolutely continuous precisely when $\mu_X\ll\mathcal L^1$.
[/step]
[step:Apply Radon-Nikodym to obtain a density from absolute continuity]
Assume that $X$ is absolutely continuous. Then $\mu_X\ll\mathcal L^1$. The measure $\mu_X$ is a finite measure because $\mu_X(\mathbb R)=1$, and $\mathcal L^1$ is $\sigma$-finite on $\mathbb R$ because
\begin{align*}
\mathbb R=\bigcup_{m\in\mathbb N}[-m,m],
\qquad
\mathbb N:=\{1,2,3,\ldots\},
\qquad
\mathcal L^1([-m,m])=2m<\infty.
\end{align*}
Therefore the hypotheses of the [Radon-Nikodym Theorem](/theorems/???) apply to the measures $\mu_X$ and $\mathcal L^1$ on $(\mathbb R,\mathcal B(\mathbb R))$. Hence there exists a nonnegative Borel measurable function
\begin{align*}
f_X:(\mathbb R,\mathcal B(\mathbb R))&\to([0,\infty],\mathcal B([0,\infty]))
\end{align*}
such that, for every $A\in\mathcal B(\mathbb R)$,
\begin{align*}
\mu_X(A)=\int_A f_X(x)\,d\mathcal L^1(x).
\end{align*}
Using $\mu_X(A)=\mathbb P(X\in A)$ gives
\begin{align*}
\mathbb P(X\in A)=\int_A f_X(x)\,d\mathcal L^1(x)
\end{align*}
for every $A\in\mathcal B(\mathbb R)$.
[guided]
Assume that $X$ is absolutely continuous. By definition, this means that the law $\mu_X$ of $X$ is absolutely continuous with respect to Lebesgue measure:
\begin{align*}
\mu_X\ll\mathcal L^1.
\end{align*}
We want to convert this measure-theoretic absolute continuity into integration against a function. The precise tool for this conversion is the [Radon-Nikodym Theorem](/theorems/???).
We verify its hypotheses. The measure $\mu_X$ is finite because it is a probability measure:
\begin{align*}
\mu_X(\mathbb R)=\mathbb P(X\in\mathbb R)=1.
\end{align*}
The reference measure $\mathcal L^1$ is $\sigma$-finite on $\mathbb R$. Indeed, with $\mathbb N:=\{1,2,3,\ldots\}$,
\begin{align*}
\mathbb R=\bigcup_{m\in\mathbb N}[-m,m],
\qquad
\mathcal L^1([-m,m])=2m<\infty.
\end{align*}
Thus the Radon-Nikodym theorem applies to the measure space $(\mathbb R,\mathcal B(\mathbb R))$, the finite measure $\mu_X$, and the $\sigma$-finite measure $\mathcal L^1$.
The theorem gives a nonnegative Borel measurable function
\begin{align*}
f_X:(\mathbb R,\mathcal B(\mathbb R))&\to([0,\infty],\mathcal B([0,\infty]))
\end{align*}
such that
\begin{align*}
\mu_X(A)=\int_A f_X(x)\,d\mathcal L^1(x)
\end{align*}
for every $A\in\mathcal B(\mathbb R)$. Since $\mu_X(A)=\mathbb P(X\in A)$ by the definition of the law of $X$, this becomes
\begin{align*}
\mathbb P(X\in A)=\int_A f_X(x)\,d\mathcal L^1(x)
\end{align*}
for every $A\in\mathcal B(\mathbb R)$. This is exactly the density representation required in the theorem.
[/guided]
[/step]
[step:Use the density formula to recover absolute continuity]
Conversely, suppose there exists a nonnegative Borel measurable function
\begin{align*}
f_X:(\mathbb R,\mathcal B(\mathbb R))&\to([0,\infty],\mathcal B([0,\infty]))
\end{align*}
such that
\begin{align*}
\mathbb P(X\in A)=\int_A f_X(x)\,d\mathcal L^1(x)
\end{align*}
for every $A\in\mathcal B(\mathbb R)$. Let $N\in\mathcal B(\mathbb R)$ satisfy $\mathcal L^1(N)=0$. Since $f_X$ is nonnegative and Borel measurable, the defining property of the Lebesgue integral over a null set gives
\begin{align*}
\int_N f_X(x)\,d\mathcal L^1(x)=0.
\end{align*}
Therefore
\begin{align*}
\mu_X(N)=\mathbb P(X\in N)=\int_N f_X(x)\,d\mathcal L^1(x)=0.
\end{align*}
Thus $\mathcal L^1(N)=0$ implies $\mu_X(N)=0$, so $\mu_X\ll\mathcal L^1$. Hence $X$ is absolutely continuous.
[/step]
[step:Compare two candidate densities on the sets where they differ]
Suppose
\begin{align*}
f:(\mathbb R,\mathcal B(\mathbb R))&\to([0,\infty],\mathcal B([0,\infty])),\\
g:(\mathbb R,\mathcal B(\mathbb R))&\to([0,\infty],\mathcal B([0,\infty]))
\end{align*}
are nonnegative Borel measurable functions such that, for every $A\in\mathcal B(\mathbb R)$,
\begin{align*}
\mu_X(A)=\int_A f(x)\,d\mathcal L^1(x)
=\int_A g(x)\,d\mathcal L^1(x).
\end{align*}
Taking $A=\mathbb R$ gives
\begin{align*}
\int_{\mathbb R} f(x)\,d\mathcal L^1(x)
=
\int_{\mathbb R} g(x)\,d\mathcal L^1(x)
=
\mu_X(\mathbb R)=1,
\end{align*}
so both integrals are finite.
Define the Borel sets
\begin{align*}
E_+&:=\{x\in\mathbb R:f(x)>g(x)\},\\
E_-&:=\{x\in\mathbb R:g(x)>f(x)\}.
\end{align*}
We prove that $\mathcal L^1(E_+)=0$. For each $m\in\mathbb N$, define
\begin{align*}
E_{+,m}:=\{x\in\mathbb R:f(x)\ge g(x)+m^{-1}\}.
\end{align*}
Then $E_{+,m}\in\mathcal B(\mathbb R)$ and
\begin{align*}
E_+=\bigcup_{m\in\mathbb N}E_{+,m}.
\end{align*}
For each $m\in\mathbb N$, the pointwise inequality on $E_{+,m}$ gives
\begin{align*}
\int_{E_{+,m}} f(x)\,d\mathcal L^1(x)
\ge
\int_{E_{+,m}} g(x)\,d\mathcal L^1(x)
+
m^{-1}\mathcal L^1(E_{+,m}).
\end{align*}
But the density identities applied to $A=E_{+,m}$ give
\begin{align*}
\int_{E_{+,m}} f(x)\,d\mathcal L^1(x)
=
\int_{E_{+,m}} g(x)\,d\mathcal L^1(x).
\end{align*}
Since both integrals are finite, subtraction yields
\begin{align*}
m^{-1}\mathcal L^1(E_{+,m})=0,
\end{align*}
and therefore $\mathcal L^1(E_{+,m})=0$. Countable subadditivity of $\mathcal L^1$ gives
\begin{align*}
\mathcal L^1(E_+)
\le
\sum_{m\in\mathbb N}\mathcal L^1(E_{+,m})
=0.
\end{align*}
The same argument with $f$ and $g$ interchanged gives $\mathcal L^1(E_-)=0$. Hence
\begin{align*}
\{x\in\mathbb R:f(x)\ne g(x)\}=E_+\cup E_-
\end{align*}
has $\mathcal L^1$-measure zero. Thus $f=g$ $\mathcal L^1$-a.e., proving uniqueness of the density up to equality $\mathcal L^1$-a.e.
[/step]