The accurate modeling of the dielectric properties of water is crucial for many applications in physics, computational chemistry, and molecular biology. This becomes possible in the framework of nonlocal electrostatics, for which we propose a novel formulation allowing for numerical solutions for the nontrivial molecular geometries arising in the applications mentioned before. Our approach is based on the introduction of a secondary field psi, which acts as the potential for the rotation free part of the dielectric displacement field D. For many relevant models, the dielectric function of the medium can be expressed as the Green's function of a local differential operator. In this case, the resulting coupled Poisson (-Boltzmann) equations for psi and the electrostatic potential phi reduce to a system of coupled partial differential equations. The approach is illustrated by its application to simple geometries.