  The interiors of giant planets remain poorly understood. Even for the planets
in the Solar System, difficulties in observation lead to large uncertainties in
the properties of planetary cores. Exoplanets that have undergone rare
evolutionary processes provide a route to understanding planetary interiors.
Planets found in and near the typically barren hot-Neptune 'desert' (a region
in mass-radius space that contains few planets) have proved to be particularly
valuable in this regard. These planets include HD149026b, which is thought to
have an unusually massive core, and recent discoveries such as LTT9779b and
NGTS-4b, on which photoevaporation has removed a substantial part of their
outer atmospheres. Here we report observations of the planet TOI-849b, which
has a radius smaller than Neptune's but an anomalously large mass of
$39.1^{+2.7}_{-2.6}$ Earth masses and a density of $5.2^{+0.7}_{-0.8}$ grams
per cubic centimetre, similar to Earth's. Interior structure models suggest
that any gaseous envelope of pure hydrogen and helium consists of no more than
$3.9^{+0.8}_{-0.9}$ per cent of the total planetary mass. The planet could have
been a gas giant before undergoing extreme mass loss via thermal
self-disruption or giant planet collisions, or it could have avoided
substantial gas accretion, perhaps through gap opening or late formation.
Although photoevaporation rates cannot account for the mass loss required to
reduce a Jupiter-like gas giant, they can remove a small (a few Earth masses)
hydrogen and helium envelope on timescales of several billion years, implying
that any remaining atmosphere on TOI-849b is likely to be enriched by water or
other volatiles from the planetary interior. We conclude that TOI-849b is the
remnant core of a giant planet.
