The (14)C production rate in the upper atmosphere changes with time because the galactic cosmic-ray flux responsible for (14)C production is modulated by the changes in solar wind magnetic properties. The resulting changes in the atmospheric (14)C level are recorded in tree rings and are used to calculate past (14)C production rates from a carbon reservoir model that describes terrestrial carbon exchange between the atmosphere, ocean, and biosphere. These past (14)C production rate changes are compared with (14)C production rates determined from 20th-century neutron flux measurements, and a theory relating (14)C production and solar variability, as given by geomagnetic Aa indices and sunspot numbers, is developed. This theory takes into account long-term solar changes that were previously neglected. The 860-year (14)C record indicates three episodes when sunspots apparently were absent: A.D. 1654 to 1714 (Maunder minimum), 1416 to 1534 (Spörer minimum), and 1282 to 1342 (Wolf minimum). A less precisely defined minimum occurred near A.D. 1040. The part of this record after A.D. 1645 correlates well with the basic features of the historical record of sunspot numbers. The magnitude of the calculated (14)C production rates points to a further increase in cosmic-ray flux when sunspots are absent. This flux was greatest during the Spörer minimum. A record of approximate sunspot numbers and Aa indices for the current millennium is also presented.