How the Sun’s Magnetic Field Works (Infographic)
Electric currents inside the sun generate a magnetic field that spreads throughout the solar system.
The field causes activity at the surface of the sun, surging and ebbing in a regular cycle. At the peak of the cycle,
the polarity of the field flips, during a time of maximum sunspot activity.
Source SPACE.com: All about our solar system, outer space and exploration.