Palaeomagnetic measurements of meteorites suggest that, shortly after the birth of the Solar System, the molten metallic cores of many small planetary bodies convected vigorously and were capable of generating magnetic fields. Convection on these bodies is currently thought to have been thermally driven, implying that magnetic activity would have been short-lived. Here we report a time-series palaeomagnetic record derived from nanomagnetic imaging of the Imilac and Esquel pallasite meteorites, a group of meteorites consisting of centimetre-sized metallic and silicate phases. We find a history of long-lived magnetic activity on the pallasite parent body, capturing the decay and eventual shutdown of the magnetic field as core solidification completed. We demonstrate that magnetic activity driven by progressive solidification of an inner core is consistent with our measured magnetic field characteristics and cooling rates. Solidification-driven convection was probably common among small body cores, and, in contrast to thermally driven convection, will have led to a relatively late (hundreds of millions of years after accretion), long-lasting, intense and widespread epoch of magnetic activity among these bodies in the early Solar System.