All stars are magnetic. Stars are made of very hot gas called plasma where the electrons are free of the atomic nuclei. In this situation, a star can support both electric currents and magnetic fields. Magnetic fields are generated by rotation, and sustained and sometimes amplified by the convection motions that occur in the outer parts of a star. The telltale signs of magnetic fields in stars like the Sun are sunspots, where the pairs of sunspots mark locations on the photosphere where the magnetic field penetrates the surface. Sunspots have magnetic field strengths of 2000 to 3000 Gauss, but the overall polar field is much weaker, only 1 to 2 Gauss. For reference, a refrigerator magnet has a field strength of about 100 Gauss. Other stars are too far away to detect starspots so a more global method has to be used. When astronomers want to measure magnetic fields in general, they use the technique of polarimetry. This uses the fact that radiation emitted from a region with magnetic fields has its wave oscillation aligned with the dominant direction of the magnetic field, rather than randomly oriented.
In stars like the Sun, magnetic field strength increases with stellar rotation rate and with the age of the star, and its strength also correlates with activity in the chromosphere. Most stars have small magnetic fields, about 1 to 100 Gauss, and small values of the polarization of their light, 0.1 to 1%. Some types of variable stars also have strong magnetic fields and magnetic activity. One example is pre-main sequence stars called T Tauri stars, where the energy source is gravitational contraction rather than fusion. Low mass dwarf stars of 0.1 to 0.6 solar masses also have irregular variability, strong flares, and magnetic field strengths 10 to 100 times stronger than the Sun.
The strongest magnetic fields in the universe are seen in collapsed stars at the ends of their lives. If you think of a star as a kind of bar magnet with the field lines emerging like a dipole from the north and south poles of rotation, and then imagine squeezing the star, the magnetic field would be compressed and strengthened. Since the magnetic field is trapped in the star, that’s what happens when a star shrinks or collapses. If the star shrinks by a factor of two, the strength of the magnetic field goes up by a factor of four. In general field strength rises as the inverse square of star size. This tight "gripping" of the magnetic fields lines also means that in collapsed stars the field does not disappear and reverse in a cycle the way it does with the Sun.
The most compact and rapidly rotating remnants of stars are white dwarfs, neutron stars, and black holes. Nobody has ever measured the magnetic field of a black hole, but the other two types of objects have the strongest magnetic fields among any type of star. Some white dwarfs have magnetic fields a million times stronger than the Sun, or about 1 to 2 million Gauss. Neutrons stars are even smaller, so their magnetic fields can be a thousand times stronger, or ten billion (1010) Gauss. The most extreme magnetic stars are called magnetars. They have phenomenal field strengths of up to 1015 Gauss, which is like ten trillion refrigerator magnets!
In August 1998, a surge of X-rays and gamma rays was registered at the top of the Earth's atmosphere. This extraordinary pulse lasted 5 minutes and was strong enough to shut down the instruments on some sensitive satellites. It turns out the source of this high energy radiation was a special type of neutron star about 5000 pc from Earth, called a magnetar. Astronomers believe that magnets have dense neutron cores with a surrounding mile-deep crust made largely of iron. The magnetic fields are larger than any other object known — 1014 times stronger than the Earth's magnetic field! When the stresses in the spinning star are released, the solid crust can vibrate and even crack open, producing a tremendous blast of radiation. Anyone within 600 A.U. of a magnetar would receive a lethal dose of gamma rays. Luckily, magnetars are rare enough that there are none anywhere near the Sun.