Remote observations of the asteroid (1) Ceres from ground- and space-based telescopes have provided its approximate density and shape, leading to a range of models for the interior of Ceres, from homogeneous to fully differentiated. A previously missing parameter that can place a strong constraint on the interior of Ceres is its moment of inertia, which requires the measurement of its gravitational variation together with either precession rate or a validated assumption of hydrostatic equilibrium. However, Earth-based remote observations cannot measure gravity variations and the magnitude of the precession rate is too small to be detected. Here we report gravity and shape measurements of Ceres obtained from the Dawn spacecraft, showing that it is in hydrostatic equilibrium with its inferred normalized mean moment of inertia of 0.37. These data show that Ceres is a partially differentiated body, with a rocky core overlaid by a volatile-rich shell, as predicted in some studies. Furthermore, we show that the gravity signal is strongly suppressed compared to that predicted by the topographic variation. This indicates that Ceres is isostatically compensated, such that topographic highs are supported by displacement of a denser interior. In contrast to the asteroid (4) Vesta, this strong compensation points to the presence of a lower-viscosity layer at depth, probably reflecting a thermal rather than compositional gradient. To further investigate the interior structure, we assume a two-layer model for the interior of Ceres with a core density of 2,460-2,900 kilograms per cubic metre (that is, composed of CI and CM chondrites), which yields an outer-shell thickness of 70-190 kilometres. The density of this outer shell is 1,680-1,950 kilograms per cubic metre, indicating a mixture of volatiles and denser materials such as silicates and salts. Although the gravity and shape data confirm that the interior of Ceres evolved thermally, its partially differentiated interior indicates an evolution more complex than has been envisioned for mid-sized (less than 1,000 kilometres across) ice-rich rocky bodies.