The adult mouse heart responds to injury by scarring with consequent loss of contractile function, whereas the neonatal heart possesses the ability to regenerate. Activation of the immune system is among the first events upon tissue injury. It has been shown that immune response kinetics differ between regeneration and pathological remodeling, yet the underlying mechanisms of the distinct immune reactions during tissue healing remain unclear. Here we show that the immunomodulatory PD-1–PD-L1 pathway is highly active in regenerative neonatal hearts but rapidly silenced later in life. Deletion of the PD-1 receptor or inactivation of its ligand PD-L1 prevented regeneration of neonatal hearts after injury. Disruption of the pathway during neonatal cardiac injury led to increased inflammation and aberrant T cell activation, which ultimately impaired cardiac regeneration. Our findings reveal an immunomodulatory and cardioprotective role for the PD-1–PD-L1 pathway in heart regeneration and offer potential avenues for the control of adult tissue regeneration. Vargas Aguilar et al. report that the PD-1–PD-L1 checkpoint-inhibitor pathway is highly active in heart-resident and circulating immune cells of newborn mice and disruption of this pathway led to increased inflammation and pathogenic T cell activity, impairing regeneration.