Last decades, there has been an increased interest in the use of the self-potential (SP) method in hydrogeophysics. In response to this strong interest, we develop a novel approach to the inversion of SP data. Mathematically, the SP inverse problem is the source identification problem for the Poisson equation. Our approach substantially differs from the standard regularization approach, which explicitly includes the forward-problem operator into the cost functional. We formulated the inverse problem is as an optimal control problem and then translate it into a variational system. The system is approximated in suitable finite-element spaces giving rise to an algebraic problem with the saddle-point structure. In contrast to the standard approach, which leads to a dense linear system, our method results in a system with a sparse block matrix. It can be efficiently solved by either direct sparse solvers or preconditioned iterative solvers. In this paper, we present the formulation of the problem and its finite-element approximation. We discuss the iterative solution and preconditioning strategies. Our software implementation is based on an industrial finite-element package. We also present a numerical experiment with node-based linear finite elements on tetrahedral grids. Our results suggest that the proposed approach may serve as a rapid and reliable tool for large-scale SP inverse problems. Moreover, the same technique can easily be extended to a wide range of geophysical linear inverse problems, such as inversions of magnetic and gravity data.