A theoretical method is described to analytically calculate a pair of surface current densities which produce a desired static magnetic field in one region of the space, and zero magnetic field in another. The analysis is based on the known relationship between a surface current density and a stream function, the equivalence of stream functions and surface magnetic dipole density, and the scalar potential representation of the associated magnetic field in free space. From these relations, we formulate the magnetostatics problem, which is often treated as a vector field problem, as a scalar field problem in which a two-dimensional scalar field (stream function) is related to a three-dimensional one (magnetic scalar potential) via the differentiation of the electrostatic Green’s function 1/|r-rs|. It is shown that, in a coordinate system in which a separated form of the Green’s function exists (separable coordinate system), there exists a simple relationship between a harmonic component of a stream function and a harmonic component of the magnetic scalar potential. The method is applied to calculate idealized surface current patterns for actively shielded, magnetic resonance imaging (MRI) gradient coils in the Cartesian, cylindrical, and spherical coordinates.