The rapid spread of COVID-19 underscores the need for new treatments. Here we report that cannabidiol (CBD), a compound produced by the cannabis plant, inhibits SARS-CoV-2 infection. CBD and its metabolite, 7-OH-CBD, but not congeneric cannabinoids, potently block SARS-CoV-2 replication in lung epithelial cells. CBD acts after cellular infection, inhibiting viral gene expression and reversing many effects of SARS-CoV-2 on host gene transcription. CBD induces interferon expression and up-regulates its antiviral signaling pathway. A cohort of human patients previously taking CBD had significantly lower SARS-CoV-2 infection incidence of up to an order of magnitude relative to matched pairs or the general population. This study highlights CBD, and its active metabolite, 7-OH-CBD, as potential preventative agents and therapeutic treatments for SARS-CoV-2 at early stages of infection.