Background: Estimates of the association between COVID-19 vaccines and myo-/pericarditis risk vary widely across studies due to scarcity of events, especially in age- and sex-stratified analyses.Methods: Population-based cohort study with nested self-controlled risk interval (SCRI) using healthcare data from five European databases. Individuals were followed from 01/01/2020 until end of data availability (31/12/2021 latest). Outcome was first myo-/pericarditis diagnosis. Exposures were first and second dose of Pfizer, AstraZeneca, Moderna, and Janssen COVID-19 vaccines. Baseline incidence rates (IRs), and vaccine- and dose-specific IRs and rate differences were calculated from the cohort The SCRI calculated calendar time-adjusted IR ratios (IRR), using a 60-day pre-vaccination control period and dose-specific 28-day risk windows. IRRs were pooled using random effects meta-analysis.Findings: Over 35 million individuals (49·2% women, median age 39–49 years) were included, of which 57·4% received at least one COVID-19 vaccine dose. Baseline incidence of myocarditis was low. Myocarditis IRRs were elevated after vaccination in those aged < 30 years, after both Pfizer vaccine doses (IRR = 3·3, 95%CI 1·2-9.4; 7·8, 95%CI 2·6-23·5, respectively) and Moderna vaccine dose 2 (IRR = 6·1, 95%CI 1·1-33·5). An effect of AstraZeneca vaccine dose 2 could not be excluded (IRR = 2·42, 95%CI 0·96-6·07). Pericarditis was not associated with vaccination.Interpretation: mRNA-based COVID-19 vaccines and potentially AstraZeneca are associated with increased myocarditis risk in younger individuals, although absolute incidence remains low. More data on children (≤ 11 years) are needed.