The original idea was that this happened not too far below the visible surface (today we are less sure [Parker, 2000]) . As field lines become draped around the Sun, they become denser, meaning the intensity B of the wrapped field would grow, and theory predicted that a growing "magnetic pressure" (proportional to B2) would develop in the tube-like region those lines occupy. That pressure pushes plasma out of the tube, reducing its density and causing parts of the tube to float up and break the surface, becoming visible as sunspot pairs. Note that since the field's direction is reversed in opposite hemispheres, the spots leading the pair in the direction of the rotation have opposite polarities north and south of the equator.
A subtle problem needs to be addressed, however [Elsasser 1955, 1956a,b] . In a spherical geometry, like that of the Sun, magnetic fields can be divided into two classes, toroidal and poloidal fields. If the field is axially symmetric, poloidal field lines lie in meridional planes (like those of the dipole field) while toroidal field lines form circles around the axis of symmetry. However, non-symmetric modes also exist in each class--for instance the main field due to the Earth's core and observed near its surface is poloidal. In principle, every magnetic field can be resolved into toroidal and poloidal parts. If for some reason the dynamo process creating the field stopped, electric resistance would cause a gradual decay of the field, and it can be shown that each class decays independently of the other.
The scenario envisioned above began with a dipole field, which is purely poloidal. The stretching of the field line due to uneven rotation adds and amplifies a toroidal field, proportionally to the "seed" poloidal field. However, unless that "seed field" itself gets reinforced, one can foresee that after some time, electrical resistance will cause the currents that produce it to decay, and without the "seed" the entire dynamo process comes to a halt.
Resistive decay might take many millions of years, but what is actually observed is different and much faster--the reversal of the poloidal field (and hence also of the toroidal field it produces) every 11-year solar cycle. This suggests some sort of This suggests some sort of feedback, and Eugene Parker suggested [Parker, 1955, 1979, 2000] that it arose from cyclonic motion, like the one seen in hurricanes. Namely, the interaction between the rising motion of plasma above sunspots and the Sun's rotation caused the plasma to rotate around a vertical axis as it rose. Field lines embedded in the plasma were also twisted, from the toroidal wrap-around direction to the meridional direction, which returned part of their field back to the poloidal component.
The above ideas of the solar cycle were developed by the Babcock  in the 1960s. More recent work [Parker, 2000] suggests that the Sun's magnetism may extend to a substantial depth, but many unsolved questions remain, including the causes of the uneven rotation.
14. The Earth's Dynamo
If a fluid dynamo exists inside the Earth, it has to be in its core, with about half the radius of the Earth. The reason is that the process requires a conducting fluid, and the propagation of earthquake waves has suggested the core is liquid, with a solid inner core in its middle [Brush, 1980]. Its high density fits a liquid metal, generally believed to be iron (possibly, with other elements dissolved in it), a relatively abundant element. The iron has sunk to the center of the Earth because it is heavy, the same reason that molten iron sinks to the bottom of a blast furnace.
For a while, around 1950, another idea was proposed, namely that every spinning massive object developed an intrinsic magnetic field, proportional to its angular momentum. According to that view, the field asymmetries observed on the Earth's surface were due to secondary processes, such as the circulation of liquid iron in the core. While Gilbert suggested that the Earth rotated because it was magnetic, this explanation argued the opposite--the Earth was magnetic because it rotated.
Arthur Schuster (1851-1934) was the first to propose the idea [Schuster, 1912; Warwick, 1971], and its main supporter in the 20th century was Patrick M. Blackett (1897-1974), a British physicist who was awarded the 1948 Nobel prize for his work on cosmic rays [Blackett, 1947]. By then it was known that in electrons and protons, spin and magnetic moment were related: couldn't the same hold for matter at large? However, the observation that the field did not weaken in deep mines [Runcorn, 1948; includes appendix by Sydney Chapman] was evidence against the idea, and Blackett finally ruled it out by an experiment with a spinning gold sphere [Blackett, 1952].
Meanwhile other physicists--initially, Walter Elsasser at Columbia U.-- tried to find mathematical solutions to the dynamo problem [Elsasser, 1946, 1947, 1956b]. The method devised by Gauss to represent the Earth's internal field outside the region of electrical currents can be generalized to describe any toroidal and poloidal fields, and this generalization should in principle be applicable to represent the flows and fields in the Earth's core. Unfortunately, because of Cowling's "anti-dynamo" theorem, no axially symmetric solutions were expected, leading researchers to assume a most general class of fields and motions. This produced complicated relations, which led to even more complicated ones, with no closure in sight.
For a while some scientists wondered whether any solutions existed at all. Then in 1964 Stanislaw Braginsky [1964a, b] in Russia surprised the world by producing an entire class of solutions which were almost symmetric--a symmetric field, plus a small addition. Because the addition was small, the procedure converged.
All these were solutions of the "kinematic dynamo problem," in which the flow pattern of the conducting fluid could be freely specified. A realistic model of the dynamo also requires a mechanism and a source of energy driving the flow. Bullard  pointed out that a modest amount of heat generation by radioactivity would suffice. Braginsky suggested that the solidification of molten iron and its deposition on the inner core could also supply the heat which produced the flows and thus drive the dynamo effect.
Considerable progress has taken place since then [Levy, 1976, Inglis, 1981, Jacobs, 1987 (vol. 2), Buffett, 2000, Roberts and Glatzmaier, 2000]. The problem of feedback from toroidal to poloidal modes was addressed by the "alpha-mode" dynamo of Steenbeck, Krause and Rädler of the Institute of Astrophysics in Potsdam, Germany. They showed that fluid turbulence whose statistical properties had no mirror symmetry could lead to a mean electromotive force, driving electric currents whose magnitude was α times the magnetic intensity, in the direction of the underlying average field. This may be viewed as a generalization of Parker's idea for explaining the solar cycle. An interesting "dynamo experiment" in the laboratory was reported by Lowes and Wilkinson , who spun two iron cylinders (each representing an eddy) inside a container of mercury, at right angles to each other. When the angular velocity exceeded a certain value, the magnetic field jumped to a new higher plateau, and that was viewed as the initiation of dynamo action.
One interesting development has been the mathematical simulation of the dynamo process, using high-speed computers [Glatzmaier and Roberts, 1997; Glatzmaier et al., 1999; Coe et al, 2000]. The simulation assumes a heat source in the core and heat loss through the core-mantle interface. Dynamo action is generally obtained, but the complexity of the field and the frequency of main field reversals (discussed in the next section) depend greatly on the distribution of the heat loss--whether it was uniform across the interface, highest at the pole, equator or in between, etc. The simulations also found occasional "excursions" in which the field seemed to head towards a reversal but then reasserted its original polarity, a class of events also deduced from the paleomagnetic record. Interestingly, a simulation run with a much smaller inner core produced no reversals at all.