We introduce a Hamiltonian to address the Hilbert–Pólya conjecture. The eigenfunctions of the introduced Hamiltonian, subject to the Dirichlet boundary conditions on the positive half-line, vanish at the origin by the nontrivial zeros of the Riemann zeta function. Consequently, the eigenvalues are determined by these nontrivial Riemann zeros. If the Riemann hypothesis (RH) is true, the eigenvalues become real and represent the imaginary parts of the nontrivial zeros. Conversely, if the Hamiltonian is self-adjoint, or more generally, admits only real eigenvalues, then the RH follows. In our attempt to demonstrate the latter, we establish the existence of a similarity transformation of the introduced Hamiltonian that is self-adjoint on the domain specified by an appropriate boundary condition, which is satisfied by the eigenfunctions through the vanishing of the Riemann zeta function. Our result can be extended to a broader class of functions whose zeros lie on the critical line.