Approximately 4.6 billion years ago, a cold cloud of gas and dust buried deep in one of the Milky Way galaxy's spiral arms started to collapse. Perhaps strong winds from a massive star or a shock wave from a nearby supernova explosion triggered the collapse — from our distance in time, we'll never know for sure.
Whatever the cause, the force of gravity then started to work its magic: The cloud began to contract and fragment. One of those fragments was destined to become our Sun and the rest of the solar system. The other fragments also spawned stars that have long since moved away from their birthplace — there's no way to determine which ones might have been our siblings. But while the star-formation process was going full bore, our small part of the galaxy probably looked like the Orion Nebula (M42) or one of the other similar star-forming regions we see around us today.
Let's head back to our budding solar system. As gravity continued to compress the solar nebula, the central region that would become the Sun drew in the vast majority of material. Because the nebula was rotating, however, not all of the gas and dust could fall into the proto-Sun being forged at the center. Instead, some of it formed a disk that ultimately would condense into the planets and other, smaller members of the solar system.
The proto-Sun continued to contract and, as it did so, grew hotter. This persisted until its central temperature rose high enough to ignite the fires of nuclear fusion. The heat created by these nuclear reactions produced a pressure that counteracted the inward pull of gravity, and the object became the stable star we call the Sun.
The Sun continues to produce energy in the same way. In the core, where temperatures reach 15 million kelvins (about 27 million degrees Fahrenheit), positively charged protons (the nuclei of hydrogen atoms) can overcome their mutual repulsion and fuse together. In essence, four hydrogen nuclei combine into one helium nucleus in a process called the proton-proton chain. Because the helium nucleus weighs a little less than the four hydrogen nuclei combined, the reactions create energy according to Einstein's famous equation E=mc2. To keep the Sun shining, about 600 million tons of hydrogen must be converted to helium every second. Despite this prodigious consumption, the Sun has enough hydrogen to keep shining for another 5 to 6 billion years.
It can take a million years or more for the energy created at the Sun's center to fight its way to the surface, where it gets radiated into space. Despite being a huge ball of gas, the Sun appears to have a sharp edge because the energy radiates from a thin layer only a couple hundred miles thick, compared with the Sun's overall radius of 432,000 miles (695,000 kilometers).
Astronomers call this thin layer the photosphere, and it has an average temperature of about 6,000 kelvins (10,000° F). The photosphere represents the lowest level of the Sun's atmosphere. Above it lies the slightly hotter chromosphere, another thin layer that measures between 1,000 and 2,000 miles thick. Above the chromosphere lies the corona, a superheated region where temperatures rise to millions of degrees. Despite this great temperature, the corona has such a low density that we normally don't see it when looking in visible light. Only when the Moon blocks the much brighter photosphere from view during a total solar eclipse does the corona emerge into view. Because the Sun's gravity isn't strong enough to hold onto such hot gas, the outer atmosphere essentially boils off into space. This "solar wind" permeates the solar system and, among other things, causes the ionized gas tails of comets to point away from the Sun.
The most conspicuous features on the Sun are aptly called sunspots. These dark splotches belong to the photosphere and occasionally grow large enough to be visible to the naked eye from Earth. (Remember, never look directly at the Sun without using a safe solar filter.) Sunspots appear dark only in contrast to the surrounding photosphere. They glow at a temperature some 1,500 kelvins (2,700° F) cooler than the photosphere and thus don't emit as much light. However, if you could somehow remove a sunspot and place it in the night sky, it would appear quite bright.
The biggest sunspots have diameters of 25,000 to 30,000 miles, dwarfing the size of Earth. They can last anywhere from a few hours to a few months. Because the Sun rotates in slightly less than a month, some sunspots cross the solar disk more than once. Sunspots also tend to cluster, with some sunspot groups containing a hundred or more individual spots. These large groups possess strong magnetic fields and often give rise to flares, the largest explosions in the solar system. A typical flare lasts for 5 to 10 minutes and releases as much energy as a million hydrogen bombs. The biggest flares last for several hours and emit enough energy to power the United States (at its current rate of electric consumption) for 100,000 years.
Observations of sunspots over the past couple centuries show that the number of spots varies with time. This solar cycle averages about 11 years from sunspot maximum to minimum and back again. The last solar maximum occurred in 2000, and the next is predicted around 2011. Interestingly enough, the solar cycle apparently hasn't always been so. Sunspot numbers were much lower between 1645 and 1715 than now, and scientists have deduced other periods of lesser and greater activity.