We follow the treatment given in Reed and Simon.
Let $T: H \to H$ be a self-adjoint operator on a separable Hilbert space, with domain $D$. Then there exists a finite measure space $(M, \mu)$, a unitary operator $U: H \to L^2(M, \mu)$, and a real-valued function $f: M \to \mathbb{R}$ such that
$\psi \in D$ if and only if $f \cdot (U\psi) \in L^2(M, \mu)$, and
For $\psi \in D$, $U(T(\psi)) = f \cdot U(\psi)$
The last equation should be read as a diagonalization; it says that
for almost all $x \in M$.
We have yet to give a careful definition of what it means for an operator to be self-adjoint, but in outline, the proof runs roughly as follows. If $T$ is self-adjoint, then
$T + i$ and $T - i$ map $D$ bijectively onto $H$.
The maps $T + i$ and $T - i$ are closed, and therefore by the closed graph theorem, their set-theoretic inverses are (closed) bounded maps $(T + i)^{-1}$, $(T - i)^{-1}$ from $H$ to $D \subset H$.
$(T + i)^{-1}$ and $(T - i)^{-1}$ commute, and one is the adjoint of the other. Hence each is (bounded and) normal.
By the spectral theorem for bounded normal operators, there is a measure space $(M, \mu)$, a unitary isomorphism $U: H \to L^2(M, \mu)$, and a measurable, bounded, complex-valued function $g$ so that $U ((T+i)^{-1}(\phi)) = g \cdot U(\phi)$ for all $\phi \in H$.
We therefore have a commutative diagram
where $D'$ is the image of the operator given by multiplying by $g$. It follows that we have a commutative diagram
whence, if we put $f(x) = \frac1{g(x)} - i$, we obtain $U(T(\psi)) = f \cdot U(\psi)$.
We now prove these statements.
Recall that a partially defined linear operator $T: H \to H$ is closed if it has a closed graph in $H \times H$.
If $T$ is densely defined, then for each $\phi \in H$ there is at most one $\eta \in H$ for which
and the set of $\phi$ for which such $\eta$ exists defines the domain of the partially defined transpose map $T^\ast$ defined by $T^\ast(\phi) = \eta$.
If $T: H \to H$ is densely defined, then $T^\ast$ is closed.
The trick is to exhibit the graph of $T^\ast$ as the orthogonal complement of some space. This suffices because orthogonal complements are always closed…