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'1,2 (a region in mass-radius space that contains few planets) have proved to be particularly valuable in this regard. These planets include HD149026b3, which is thought to have an unusually massive core, and recent discoveries such as LTT9779b4 and NGTS-4b5, 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 [Formula: see text] Earth masses and a density of [Formula: see text] 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 [Formula: see text] 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 formation6. 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.