BackgroundAn increased risk of myocarditis or pericarditis after priming with mRNA Coronavirus Disease 2019 (COVID-19) vaccines has been shown but information on the risk post-booster is limited. With the now high prevalence of prior Severe Acute Respiratory Syndrome Coronavirus 2 (SARS-CoV-2) infection, we assessed the effect of prior infection on the vaccine risk and the risk from COVID-19 reinfection.Methods and findingsWe conducted a self-controlled case series analysis of hospital admissions for myocarditis or pericarditis in England between 22 February 2021 and 6 February 2022 in the 50 million individuals eligible to receive the adenovirus-vectored vaccine (ChAdOx1-S) for priming or an mRNA vaccine (BNT162b2 or mRNA-1273) for priming or boosting. Myocarditis and pericarditis admissions were extracted from the Secondary Uses Service (SUS) database in England and vaccination histories from the National Immunisation Management System (NIMS); prior infections were obtained from the UK Health Security Agency’s Second-Generation Surveillance Systems. The relative incidence (RI) of admission within 0 to 6 and 7 to 14 days of vaccination compared with periods outside these risk windows stratified by age, dose, and prior SARS-CoV-2 infection for individuals aged 12 to 101 years was estimated. The RI within 27 days of an infection was assessed in the same model. There were 2,284 admissions for myocarditis and 1,651 for pericarditis in the study period. Elevated RIs were only observed in 16- to 39-year-olds 0 to 6 days postvaccination, mainly in males for myocarditis. Both mRNA vaccines showed elevated RIs after first, second, and third doses with the highest RIs after a second dose 5.34 (95% confidence interval (CI) [3.81, 7.48];p< 0.001) for BNT162b2 and 56.48 (95% CI [33.95, 93.97];p< 0.001) for mRNA-1273 compared with 4.38 (95% CI [2.59, 7.38];p< 0.001) and 7.88 (95% CI [4.02, 15.44];p< 0.001), respectively, after a third dose. For ChAdOx1-S, an elevated RI was only observed after a first dose, RI 5.23 (95% CI [2.48, 11.01];p< 0.001). An elevated risk of admission for pericarditis was only observed 0 to 6 days after a second dose of mRNA-1273 vaccine in 16 to 39 year olds, RI 4.84 (95% CI [1.62, 14.01];p= 0.004). RIs were lower in those with a prior SARS-CoV-2 infection than in those without, 2.47 (95% CI [1.32,4.63];p= 0.005) versus 4.45 (95% [3.12, 6.34];p= 0.001) after a second BNT162b2 dose, and 19.07 (95% CI [8.62, 42.19];p< 0.001) versus 37.2 (95% CI [22.18, 62.38];p< 0.001) for mRNA-1273 (myocarditis and pericarditis outcomes combined). RIs 1 to 27 days postinfection were elevated in all ages and were marginally lower for breakthrough infections, 2.33 (95% CI [1.96, 2.76];p< 0.001) compared with 3.32 (95% CI [2.54, 4.33];p< 0.001) in vaccine-naïve individuals respectively.ConclusionsWe observed an increased risk of myocarditis within the first week after priming and booster doses of mRNA vaccines, predominantly in males under 40 years with the highest risks after a second dose. The risk difference between the second and the third doses was particularly marked for the mRNA-1273 vaccine that contains half the amount of mRNA when used for boosting than priming. The lower risk in those with prior SARS-CoV-2 infection, and lack of an enhanced effect post-booster, does not suggest a spike-directed immune mechanism. Research to understand the mechanism of vaccine-associated myocarditis and to document the risk with bivalent mRNA vaccines is warranted.