The interiors of giant planets remain poorly understood. Even for the planets in the Solar System, difficulties in observation lead to major uncertainties in the properties of planetary cores. Exoplanets that have undergone rare evolutionary pathways provide a new route to understanding planetary interiors. We present the discovery of TOI-849b, the remnant core of a giant planet, with a radius smaller than Neptune but an anomalously high mass M p =40.8 +2.4 −2.5 M ⊕ and density of 5.5 ± 0.8 gcm −3 , similar to the Earth. Interior structure models suggest that any gaseous envelope of pure hydrogen and helium consists of no more than 3.9 +0.8 −0.9 % of the total mass of the planet. TOI-849b transits a late G type star (T mag = 11.5) with an orbital period of 18.4 hours, leading to an equilibrium temperature of 1800K. The planet's mass is larger than the theoretical threshold mass for runaway gas accretion. As such, the planet could have been a gas giant before undergoing extreme mass loss via thermal self-disruption or giant planet collisions, or it avoided substantial gas accretion, perhaps through gap opening or late formation. Photoevaporation rates cannot provide the mass loss required to reduce a Jupiter-like gas giant, but can remove a few M ⊕ hydrogen and helium envelope on timescales of several Gyr, implying that any remaining atmosphere is likely to be enriched by water or other volatiles from the planetary interior. TOI-849b represents a unique case where material from the primordial core is left over from formation and available to study.