S U M M A R YTheoretical models of the viscoelastic relaxation of a spherical Earth are derived to model large-scale postseismic deformation resulting from great earthquakes (M > 7) over decadal timescales. Most existing models of postseismic deformation do not consider strong lateral heterogeneities in mantle viscosity, in particular in the subducting slab where such events occur. In addition, the self-gravitation effect is often treated only approximately. Both effects become important when observations from space geodetic techniques such as GPS and GRACE are interpreted. In this paper, we present a spectral finite-element approach that allows these two effects to be considered in a rigorous way. In this way, much larger lateral viscosity variations can be handled than by perturbation techniques. We derive interface conditions for an arbitrary shear fault in the form of double-couple forces that are equivalent to a prescribed dislocation and simulate a relaxation process for an incompressible Maxwell earth with a 3-D viscoelastic structure. Computational results are validated for a spherically symmetric model by an independent method based on the inverse Laplace integration, and good agreement is obtained. As an example, we apply this approach to the 2004 Sumatra-Andaman earthquake and simulate a large-scale postseismic gravity potential variation by a forward calculation. In the presence of a slab, the secular variation in geoid height change decreases by 30 per cent for wavelengths longer than 500 km, with respect to the case excluding the slab. The effect of the slab can exceed 0.3 mm yr −1 for short-term variations when the asthenosphere viscosity is 10 19 Pa s, which are larger than the observation errors of GRACE. For a displacement field, a decrease in deformation rates can amount to 70 per cent due to the inclusion of a slab, which is detectable with geodetic observations such as GPS. The effect of the slab is attenuated in the gravity field for such longer wavelengths since horizontal scales of the slab are smaller than its spatial resolution. Lateral heterogeneities in viscosity due to a slab should therefore be considered for interpreting observed postseismic relaxation due to a large thrust event in a subduction zone.