It is uncertain whether the Moon ever formed a metallic core or generated a core dynamo. The lunar crust and returned samples are magnetized, but the source of this magnetization could be meteoroid impacts rather than a dynamo. Here, we report magnetic measurements and 40Ar/39Ar thermochronological calculations for the oldest known unshocked lunar rock, troctolite 76535. These data imply that there was a long-lived field on the Moon of at least 1 microtesla ~4.2 billion years ago. The early age, substantial intensity, and long lifetime of this field support the hypothesis of an ancient lunar core dynamo.