A key unknown in lunar science is to what extent is the Moon is a melted, radially layered planet like Earth or a primordial relic of the early solar system, like many asteroids. A new era of lunar exploration is underway, offering major new insights into this decades-old question. Although the Moon today has no global magnetic field, new laboratory and spacecraft measurements strongly indicate that remanent magnetization in lunar rocks is the product of an ancient core dynamo. This confirms that the Moon is a highly differentiated object that formed an advecting, liquid metallic core. The dynamo field persisted from at least 4.25 to 3.56 billion years ago with an intensity reaching that of the present Earth. The field then declined by at least an order of magnitude by 3.3 Ga. The mechanisms for sustaining such an intense and long-lived dynamo are uncertain but may include exotic mechanisms like mechanical stirring by the processing mantle.