BACKGROUND: Natural and vaccine-induced immunity will play a key role in controlling the SARS-CoV-2 pandemic. SARS-CoV-2 variants have the potential to evade natural and vaccine-induced immunity. METHODS: In a longitudinal cohort study of healthcare workers (HCWs) in Oxfordshire, UK, we investigated the protection from symptomatic and asymptomatic PCR-confirmed SARS-CoV-2 infection conferred by vaccination (Pfizer-BioNTech BNT162b2, Oxford-AstraZeneca ChAdOx1 nCOV-19) and prior infection (determined using anti-spike antibody status), using Poisson regression adjusted for age, sex, temporal changes in incidence and role. We estimated protection conferred after one versus two vaccinations and from infections with the B.1.1.7 variant identified using whole genome sequencing. RESULTS: 13,109 HCWs participated; 8285 received the Pfizer-BioNTech vaccine (1407 two doses) and 2738 the Oxford-AstraZeneca vaccine (49 two doses). Compared to unvaccinated seronegative HCWs, natural immunity and two vaccination doses provided similar protection against symptomatic infection: no HCW vaccinated twice had symptomatic infection, and incidence was 98% lower in seropositive HCWs (adjusted incidence rate ratio 0.02 [95%CI <0.01-0.18]). Two vaccine doses or seropositivity reduced the incidence of any PCR-positive result with or without symptoms by 90% (0.10 [0.02-0.38]) and 85% (0.15 [0.08-0.26]) respectively. Single-dose vaccination reduced the incidence of symptomatic infection by 67% (0.33 [0.21-0.52]) and any PCR-positive result by 64% (0.36 [0.26-0.50]). There was no evidence of differences in immunity induced by natural infection and vaccination for infections with S-gene target failure and B.1.1.7. CONCLUSION: Natural infection resulting in detectable anti-spike antibodies and two vaccine doses both provide robust protection against SARS-CoV-2 infection, including against the B.1.1.7 variant.