Magnetic fields play a part in almost all stages of stellar evolution. Most low-mass stars, including the Sun, show surface fields that are generated by dynamo processes in their convective envelopes. Intermediate-mass stars do not have deep convective envelopes, although 10 per cent exhibit strong surface fields that are presumed to be residuals from the star formation process. These stars do have convective cores that might produce internal magnetic fields, and these fields might survive into later stages of stellar evolution, but information has been limited by our inability to measure the fields below the stellar surface.
Here we report the strength of dipolar oscillation modes for a sample of 3,600 red giant stars. About 20 per cent of our sample show mode suppression, by strong magnetic fields in the cores, but this fraction is a strong function of mass. Strong core fields occur only in red giants heavier than 1.1 solar masses, and the occurrence rate is at least 50 per cent for intermediate-mass stars (1.6-2.0 solar masses), indicating that powerful dynamos were very common in the previously convective cores of these stars.