Abstract. We use a boundary perturbation technique based on the calculus of moving surfaces to compute the gravitational potential for near-spherical geometries with piecewise constant densities. The perturbation analysis is carried out to third order in the small parameter. The presented technique can be adapted to a broad range of potential problems including geometries with variable densities and surface density distributions that arise in electrostatics. The technique is applicable to arbitrary small perturbations of a spherically symmetric configuration and, in principle, to arbitrary initial domains. However, the Laplace equation for an arbitrary domain can usually be solved only numerically. We therefore concentrate on spherical domains which yield a number of geophysical applications.As an illustration, we apply our analysis to the case of a near spherical triaxial ellipsoid and show that third order estimates for ellipticities such as that of the Earth are accurate to ten digits. We include an appendix that contains a concise, but complete, exposition of the tensor calculus of moving interfaces.1. Introduction. This paper demonstrates how to use the calculus of moving surfaces to compute the gravitational potential for near spherical geometries based on a perturbation theory approach. Our expressions apply equally well (with a minus sign!) to the electrostatic potential when no surface charges are present.The perturbation of the potential is induced by a small deformation of the boundary of the domain. Our analysis applies to an arbitrary sufficiently smooth small deformation. We consider the case of constant density which can be extended to piecewise constant by the superposition principle. We do not consider the case of varying density, since the most challenging and interesting part of the analysis deals with the density discontinuities at the boundary of the domain. The presented technique can also be applied to boundary density distributions that arise in the analysis of the electrostatic potential of a conductor.