Background Preapproval trials showed that messenger RNA (mRNA)–based vaccines against severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) had a good safety profile, yet these trials were subject to size and patient-mix limitations. An evaluation of the safety of the BNT162b2 mRNA vaccine with respect to a broad range of potential adverse events is needed. Methods We used data from the largest health care organization in Israel to evaluate the safety of the BNT162b2 mRNA vaccine. For each potential adverse event, in a population of persons with no previous diagnosis of that event, we individually matched vaccinated persons to unvaccinated persons according to sociodemographic and clinical variables. Risk ratios and risk differences at 42 days after vaccination were derived with the use of the Kaplan–Meier estimator. To place these results in context, we performed a similar analysis involving SARS-CoV-2–infected persons matched to uninfected persons. The same adverse events were studied in the vaccination and SARS-CoV-2 infection analyses. Results In the vaccination analysis, the vaccinated and control groups each included a mean of 884,828 persons. Vaccination was most strongly associated with an elevated risk of myocarditis (risk ratio, 3.24; 95% confidence interval [CI], 1.55 to 12.44; risk difference, 2.7 events per 100,000 persons; 95% CI, 1.0 to 4.6), lymphadenopathy (risk ratio, 2.43; 95% CI, 2.05 to 2.78; risk difference, 78.4 events per 100,000 persons; 95% CI, 64.1 to 89.3), appendicitis (risk ratio, 1.40; 95% CI, 1.02 to 2.01; risk difference, 5.0 events per 100,000 persons; 95% CI, 0.3 to 9.9), and herpes zoster infection (risk ratio, 1.43; 95% CI, 1.20 to 1.73; risk difference, 15.8 events per 100,000 persons; 95% CI, 8.2 to 24.2). SARS-CoV-2 infection was associated with a substantially increased risk of myocarditis (risk ratio, 18.28; 95% CI, 3.95 to 25.12; risk difference, 11.0 events per 100,000 persons; 95% CI, 5.6 to 15.8) and of additional serious adverse events, including pericarditis, arrhythmia, deep-vein thrombosis, pulmonary embolism, myocardial infarction, intracranial hemorrhage, and thrombocytopenia. Conclusions In this study in a nationwide mass vaccination setting, the BNT162b2 vaccine was not associated with an elevated risk of most of the adverse events examined. The vaccine was associated with an excess risk of myocarditis (1 to 5 events per 100,000 persons). The risk of this potentially serious adverse event and of many other serious adverse events was substantially increased after SARS-CoV-2 infection. (Funded by the Ivan and Francesca Berkowitz Family Living Laboratory Collaboration at Harvard Medical School and Clalit Research Institute.)