A growing body of evidence suggests that vitamin D deficiency has been associated with an increased susceptibility to viral and bacterial respiratory infections. In this study, we aimed to examine the association between vitamin D and COVID-19 risk and outcomes. We used logistic regression to identify associations between vitamin D variables and COVID-19 (risk of infection, hospitalisation and death) in 417,342 participants from UK Biobank. We subsequently performed a Mendelian Randomisation (MR) study to look for evidence of a causal effect. In total, 1746 COVID-19 cases (399 deaths) were registered between March and June 2020. We found no significant associations between COVID-19 infection risk and measured 25-OHD levels after adjusted for covariates, but this finding is limited by the fact that the vitamin D levels were measured on average 11 years before the pandemic. Ambient UVB was strongly and inversely associated with COVID-19 hospitalization and death overall and consistently after stratification by BMI and ethnicity. We also observed an interaction that suggested greater protective effect of genetically-predicted vitamin D levels when ambient UVB radiation is stronger. The main MR analysis did not show that genetically-predicted vitamin D levels are causally associated with COVID-19 risk (OR = 0.77, 95% CI 0.55-1.11, P = 0.160), but MR sensitivity analyses indicated a potential causal effect (weighted mode MR: OR = 0.72, 95% CI 0.55-0.95, P = 0.021; weighted median MR: OR = 0.61, 95% CI 0.42-0.92, P = 0.016). Analysis of MR-PRESSO did not find outliers for any instrumental variables and suggested a potential causal effect (OR = 0.80, 95% CI 0.66-0.98, p-val = 0.030). In conclusion, the effect of vitamin D levels on the risk or severity of COVID-19 remains controversial, further studies are needed to validate vitamin D supplementation as a means of protecting against worsened COVID-19.