Obesity may affect an individual's immune response and subsequent risk of infection, such as a SARS-CoV-2 infection. It is less clear whether overweight and long-term obesity also constitute risk factors. We investigated the association between the degree and duration of overweight and obesity and SARS-CoV-2 infection. We analyzed data from nine prospective population-based cohorts of the Netherlands Cohorts Consortium, with a total of 99,570 participants, following a standardized procedure. Body mass index (BMI) and waist circumference (WC) were assessed two times before the pandemic, with approximately 5 years between measurements. SARS-CoV-2 infection was defined by self-report as a positive PCR or rapid-antigen test or as COVID-19 ascertained by a physician between March 2020 and January 2023. For three cohorts, information on SARS-CoV-2 infection by serology was available. Results were pooled using random-effects meta-analyses and adjusted for age, sex, educational level, and number of SARS-CoV-2 infection measurements. Individuals with overweight (25 ≤ BMI < 30 kg/m2) (odds ratio (OR) = 1.08, 95%-confidence interval (CI) 1.04-1.13) or obesity (BMI ≥ 30 kg/m2) (OR = 1.43, 95%-CI 1.18-1.75) were more likely to report SARS-CoV-2 infection than individuals with a healthy body weight. We observed comparable ORs for abdominal overweight (men: 94 cm≤WC < 102 cm, women: 80 cm≤WC < 88 cm) (OR = 1.09, 95%-CI 1.04-1.14, I2 = 0%) and abdominal obesity (men: WC ≥ 102 cm, women: WC ≥ 88 cm) (OR = 1.24, 95%-CI 0.999-1.55, I2 = 57%). Individuals with obesity long before the pandemic, but with a healthy body weight or overweight just before the pandemic, were not at increased risk. Overweight and obesity were associated with increased risk of SARS-CoV-2 infection with stronger associations for obesity. Individuals with a healthier weight prior to the pandemic but previous obesity did not have an increased risk of SARS-CoV-2, suggesting that weight loss in those with obesity reduces infection risk. These results underline the importance of obesity prevention and weight management for public health.