Objectives: To estimate the protective effect of previous infections and vaccinations on SARS-CoV-2 Omicron infection. Design: Prospective cohort study Setting: Community-based cohort, the Netherlands Participants: 43,257 Community-dwelling adults aged 18-85 years contributed 8,291,966 person-days between 10 January 2022 and 1 September 2022. Main outcome measures: SARS-CoV-2 infection, defined as either a reported positive (self-administered) antigen or PCR test, or seroconversion or 4-fold increase in Nucleoprotein-antibodies, based on 6-monthly serum samples. Cox proportional hazard models were used with SARS-CoV-2 infection and any COVID-19 vaccination as time-varying exposures, calendar time as underlying time scale and adjustment for age, sex, medical risk and educational level. Results: In participants with 2, 3 or 4 prior immunizing events (vaccination or previous infection), we found a relative reduction of 71-85% in Omicron infection in weeks 4-10 post-last event with hybrid immunity compared to vaccine-induced immunity. Differences in risk of infection were partly explained by differences in anti-Spike RBD (S) antibody concentration, which showed a similar pattern but with smaller differences between vaccine-induced and hybrid immunity. Compared to the lowest quartile, participants in subsequent quartiles of S-antibody concentrations had 19%, 35% and 71% reduced risk of infection, respectively. Among participants with hybrid immunity, with one previous pre-Omicron infection, there was no relevant difference in risk of Omicron infection by sequence of vaccination(s) and infection). Regardless of the type of previous immunizing events, additional events increased the protection against infection, but not above the level of the first weeks after the previous event. Conclusions: Our results showed that hybrid immunity is more protective against infection with SARS-CoV-2 Omicron than vaccine-induced immunity, up to at least 30 weeks after the last immunizing event. Among those with hybrid immunity, the sequence and number of immunizing events was not found to be of importance, and its protective effect was partly explained by circulating S-antibodies. In our population with a high level of immunity, additional immunizing events reduced risk of infection with Omicron variants only temporarily. Trial registration: Dutch Trial Register (NTR), registration number NL9279 (available via ICTRP Search Portal (who.int))