Analyses of lunar rocks and magnetic field data from orbit show that the Moon once had a global magnetic field generated by an internal dynamo. Magnetization of the deep crust implies that a dynamo operated during the first 100 million years following crust formation and magnetization of some impact basins implies that the dynamo continued into the Nectarian period. Paleomagnetic analyses of Apollo samples provide evidence for dynamo activity from about 4.25 billion years ago (Ga) until at least 1.92 Ga, ceasing thereafter by ~0.80 Ga. The field strength was Earth-like until about 3.56 Ga (from ~40 to 110 μT), after which it decreased by more than an order of magnitude. Several mechanisms have been proposed to account for the long duration of the lunar dynamo. These include thermal convection in the core that could power a dynamo for a few hundred million years, core crystallization that could power a dynamo until about 1.5 Ga, mantle and/or inner core precession that could power a dynamo beyond 2 Ga, impact-induced changes in the rotation rate of the mantle that could power several short-lived dynamos up until when the last basin formed at ~3.7 Ga, and a basal magma ocean that could have potentially powered a dynamo over much of lunar history. Magnetohydrodynamic simulations have shown that the amplification of pre-existing fields by impact generated plasmas are insufficient and too short lived to have played an important role in crustal magnetization. Some of the magnetic carriers responsible for crustal magnetization, such as those responsible for the magnetization of the deep highland crust and mare basalts, are of lunar origin. Other magnetic carriers may instead be derived from meteoritic materials that were accreted to the Moon during large impacts. Outstanding questions in lunar magnetism include the geometry of the internally generated magnetic field, the exceedingly high surface field strengths implied by some paleomagnetic analyses, whether dynamo activity was continuous or episodic, the origin of strong crustal magnetic anomalies that have no correlation with surface geology, and the mechanisms that powered the lunar dynamo through time