The adult mammalian heart is non-regenerative owing to the post-mitotic nature of cardiomyocytes. The neonatal mouse heart can regenerate, but only during the first week of life. Here we show that changes in the composition of the extracellular matrix during this week can affect cardiomyocyte growth and differentiation in mice. We identify agrin, a component of neonatal extracellular matrix, as required for the full regenerative capacity of neonatal mouse hearts. In vitro, recombinant agrin promotes the division of cardiomyocytes that are derived from mouse and human induced pluripotent stem cells through a mechanism that involves the disassembly of the dystrophin–glycoprotein complex, and Yap- and ERK-mediated signalling. In vivo, a single administration of agrin promotes cardiac regeneration in adult mice after myocardial infarction, although the degree of cardiomyocyte proliferation observed in this model suggests that there are additional therapeutic mechanisms. Together, our results uncover a new inducer of mammalian heart regeneration and highlight fundamental roles of the extracellular matrix in cardiac repair.