The SARS-CoV-2 RNA genome contains a 5′-cap that facilitates translation of viral proteins, protection from exonucleases and evasion of the host immune response1-4. How this cap is made is not completely understood. Here, we reconstitute the SARS-CoV-2 7MeGpppA2′-O-Me-RNA cap using virally encoded non-structural proteins (nsps). We show that the kinase-like NiRAN domain5 of nsp12 transfers RNA to the amino terminus of nsp9, forming a covalent RNA-protein intermediate (a process termed RNAylation). Subsequently, the NiRAN domain transfers RNA to GDP, forming the cap core structure GpppA-RNA. The nsp146 and nsp167 methyltransferases then add methyl groups to form functional cap structures. Structural analyses of the replication-transcription complex bound to nsp9 identified key interactions that mediate the capping reaction. Furthermore, we demonstrate in a reverse genetics system8 that the N-terminus of nsp9 and the kinase-like active site residues in the NiRAN domain are required for successful SARS-CoV-2 replication. Collectively, our results reveal an unconventional mechanism by which SARS-CoV-2 caps its RNA genome, thus exposing a new target in the development of antivirals to treat COVID-19.