Intervention strategies are urgently needed to control the SARS-CoV-2 (severe acute respiratory syndrome coronavirus 2) pandemic. The trimeric viral spike (S) protein catalyzes fusion between viral and target cell membranes to initiate infection. Here we report two cryo-EM structures, derived from a preparation of the full-length S protein, representing its prefusion (2.9Å resolution) and postfusion (3.0Å resolution) conformations, respectively. The spontaneous transition to the postfusion state is independent of target cells. The prefusion trimer has three receptor-binding domains clamped down by a segment adjacent to the fusion peptide. The postfusion structure is strategically decorated by N-linked glycans, suggesting possible protective roles against host immune responses and harsh external conditions. These findings advance our understanding of SARS-CoV-2 entry and may guide development of vaccines and therapeutics.