The Chinese Insight-HXMT x-ray telescope has been used to measure the strongest magnetic field in the universe. The magnetic field is in the process of being cannibalized by another object.
Thankfully, magnetars are rare. The strongest magnetic fields can be powered up by a special kind of star.
Astronomers don't know the origin of the fields, but they have suspicions. Small populations of protons and electrons can be found in neutron stars. A strong magnetic field can be created when charged particles in a supernova explode. The magnetic field in normal neutron stars is quickly melted away by the explosion. The magnetic field is locked in before that happens. The magnetic strength of the star is retained when it is revealed.
Calculating the strength of the magnetar magnetic field is one of the things that astronomer have to do. Astronomers can get lucky occasionally.
The Chinese Insight-HXMT observatory was used to study the ultraliminous pulsar J3.6+6124. There is a companion that wanders too close. The material of the companion is being torn apart by the extreme gravity of the pulsar.
A flash of bright x-rays can be seen when the gas in the accretion disk flares. The absorption line was found in the x-ray spectrum. The observatory was able to measure the magnetic field strengths thanks to the observation.
The Earth's magnetic field is about a million billion times stronger than the field estimated by them.