The magnetic fields that dominate the structure of the Sun's atmosphere are
controlled by processes in the solar interior, which cannot be directly ob
served. Magnetic activity is found in all stars with deep convective envelo
pes: young and rapidly rotating stars are very active but cyclic activity o
nly appears in slow rotators. The Sun's 11-year activity cycle corresponds
to a 22-year magnetic cycle, since the sunspot fields (which are antisymmet
ric about the equator) reverse at each minimum. The record of magnetic acti
vity is aperiodic and is interrupted by episodes of reduced activity, such
as the Maunder Minimum in the seventeenth century, when sunspots almost com
pletely disappeared. The proxy record from cosmogenic isotopes shows that s
imilar grand minima recur at intervals of around 200 yr. The Sun's large-sc
ale field is generated by dynamo action rather than by an oscillator. Syste
matic magnetic cycles are apparently produced by a dynamo located in a regi
on of weak convective overshoot at the base of the convection zone, where t
here are strong radial gradients in the angular velocity Omega. The crucial
parameter (the dynamo number) increases with increasing Omega and kinemati
c (linear) theory shows that dynamo action can set in at an oscillatory (Ho
pf) bifurcation that is probably subcritical. Although it has been demonstr
ated that the whole process works in a self-consistent model, most calculat
ions have relied on mean-field dynamo theory. This approach is physically p
lausible but can only be justified under conditions that do not apply in th
e Sun. Still, mean-field dynamos do reproduce the butterfly diagram and oth
er key features of the solar cycle. An alternative approach is to study gen
eric behaviour in low-order models, which exhibit two forms of modulation,
associated with symmetry-breaking and with reduced activity. Comparison wit
h observed behaviour suggests that modulation of the solar cycle is indeed
chaotic, i.e. deterministically rather than stochastically driven.