A safe and effective vaccine against COVID-19 is urgently needed in quantities that are sufficient to immunize large populations. Here we report the preclinical development of two vaccine candidates (BNT162b1 and BNT162b2) that contain nucleoside-modified messenger RNA that encodes immunogens derived from the spike glycoprotein (S) of SARS-CoV-2, formulated in lipid nanoparticles. BNT162b1 encodes a soluble, secreted trimerized receptor-binding domain (known as the RBD-foldon). BNT162b2 encodes the full-length transmembrane S glycoprotein, locked in its prefusion conformation by the substitution of two residues with proline (S(K986P/V987P); hereafter, S(P2) (also known as P2 S)). The flexibly tethered RBDs of the RBD-foldon bind to human ACE2 with high avidity. Approximately 20% of the S(P2) trimers are in the two-RBD 'down', one-RBD 'up' state. In mice, one intramuscular dose of either candidate vaccine elicits a dose-dependent antibody response with high virus-entry inhibition titres and strong T-helper-1 CD4+ and IFNγ+CD8+ T cell responses. Prime-boost vaccination of rhesus macaques (Macaca mulatta) with the BNT162b candidates elicits SARS-CoV-2-neutralizing geometric mean titres that are 8.2-18.2× that of a panel of SARS-CoV-2-convalescent human sera. The vaccine candidates protect macaques against challenge with SARS-CoV-2; in particular, BNT162b2 protects the lower respiratory tract against the presence of viral RNA and shows no evidence of disease enhancement. Both candidates are being evaluated in phase I trials in Germany and the USA1-3, and BNT162b2 is being evaluated in an ongoing global phase II/III trial (NCT04380701 and NCT04368728).