Main

Contrary to an initial notion of slow evolution1, the severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) has demonstrated rapid evolutionary changes over short timescales1,2,3, consistent with those of coronaviruses and RNA viruses in general1. In the pre-Omicron era, various divergent lineages of SARS-CoV-2 emerged, giving rise to distinct variants such as Alpha, Beta and Delta1, each with its specific phenotypic traits1,4,5,6.

However, the emergence of the Omicron variant in late 2021 marked a major shift, as it harboured dozens of further mutations in the spike gene compared with its predecessors1,2. Since then, the Omicron lineage has continued to evolve, leading to the emergence of new variants1,2. These rapid evolutionary changes have sparked concerns regarding their potential implications for immune evasion, transmissibility, disease severity, diagnostic accuracy and the effectiveness of existing vaccines and treatments1,3.

SARS-CoV-2 infection has been shown to provide protective effects against reinfection under various scenarios, such as during the dominance of different strains7,8,9 and against specific variants10,11,12,13. Studies have also investigated the waning of immune protection conferred by pre-Omicron infection against both pre-Omicron and Omicron reinfections7,8,9,14. However, investigations into the durability of this protection have been limited with existing studies focusing on relatively short timeframes because of the recentness of the pandemic. Notably, the durability of Omicron infection in preventing reinfection with Omicron itself over extended periods of time remains unknown.

In this study, our objective was to examine the consequences of viral evolution, particularly the transition from the pre-Omicron era to the Omicron era, on the level and durability of protection provided by natural immunity. Natural immunity refers here to the protection gained from a previous infection against reinfection and against severe, critical or fatal coronavirus disease 2019 (COVID-19) on reinfection. We specifically investigated the level and durability of the effectiveness of Omicron infection in preventing reinfection with an Omicron virus, contrasting it with the effectiveness of a pre-Omicron infection in preventing reinfection with a pre-Omicron virus.

The effectiveness of natural infection against reinfection was estimated in Qatar’s population, both overall and by time since previous infection, using the test-negative, case-control study design11,12,15,16. Cases (SARS-CoV-2-positive tests) and controls (SARS-CoV-2-negative tests) were matched exactly one-to-two by sex, 10-year age group, nationality, number of coexisting conditions, number of vaccine doses, calendar week of the SARS-CoV-2 test, method of testing (polymerase chain reaction (PCR) or rapid antigen) and reason for testing, to balance observed confounders that could influence the risk of infection across the exposure groups17.

Whereas evidence on viral evolution and immunity at the molecular level indicates the continuing emergence of new SARS-CoV-2 variants with resistance to neutralization by plasma from recovered individuals and sera from vaccinated individuals1,2,18,19,20, the implications of these findings for the population-level phenomenon of immune protection remain uncertain. The present study provides direct population-level evidence contrasting the functional impact of viral evolution on immune protection in the pre-Omicron versus Omicron eras.

Study populations

Extended Data Figures 1 and 2 illustrate the process of selecting the study populations for estimating the effectiveness of a pre-Omicron infection in preventing reinfection with a pre-Omicron virus and of an Omicron infection in preventing reinfection with an Omicron virus, respectively. Extended Data Figure 3 describes infection incidence at times of dominance of different SARS-CoV-2 variants in Qatar.

Extended Data Table 1 shows the characteristics of the study populations. The study was carried out on Qatar’s entire population; therefore, the study population is representative of the internationally diverse but predominantly young and male demographic of the country.

Immune protection in the pre-Omicron era

The overall effectiveness of a pre-Omicron infection in preventing reinfection, regardless of symptoms, with a pre-Omicron virus was estimated at 81.1% (95% confidence interval (CI), 80.4–81.8%) (Table 1a and Fig. 1a). The median duration between the previous infection and the study SARS-CoV-2 test was 252 days (interquartile range (IQR), 175–313 days). This robust protection showed limited waning over time after the previous infection. Effectiveness was 81.3% (95% CI, 80.6–82.1%) in the first year after the previous infection and 79.5% (95% CI, 77.1–81.5%) thereafter.

Table 1 Effectiveness of previous infection against reinfection
Fig. 1: Effectiveness of previous infection against reinfection.
figure 1

a,b, Effectiveness of infection in preventing reinfection regardless of symptoms (a) and in preventing severe, critical or fatal COVID-19 on reinfection (b), by time since the previous infection. a, Includes 384,231 and 684,257 independent samples for cases and controls, respectively, in the pre-Omicron era analysis, and 269,991 and 432,955 independent samples for each of cases and controls, respectively, in the Omicron era analysis. Panel b includes 9,833 and 37,698 independent samples for cases and controls, respectively, in the pre-Omicron era analysis, and 230 and 650 independent samples for each of cases and controls, respectively, in the Omicron era analysis. Data are presented as effectiveness point estimates and corresponding 95% CIs. Error bars indicate the 95% CIs. Measures were not adjusted for multiplicity. In this figure, the 95% CIs are exceedingly small, rendering them barely noticeable for the protection against reinfection in both pre-Omicron and Omicron analyses, as well as for the protection against severe, critical or fatal COVID-19 on reinfection in the pre-Omicron era. This is attributed to the very large sample sizes in these analyses. However, because of the small number of cases of severe forms of COVID-19 in the Omicron era, the 95% CIs are very wide for the protection against severe, critical or fatal COVID-19 on reinfection in the Omicron era. aThe negative lower bound for the CI was truncated because the CI was too wide.

The effectiveness of a pre-Omicron infection in preventing symptomatic reinfection with a pre-Omicron virus demonstrated a similar pattern to that observed for any reinfection (Table 2a). The overall effectiveness against symptomatic reinfection was 86.8% (95% CI, 85.7–87.9%), with no evidence of waning over time after the previous infection. The median duration between the previous infection and the study SARS-CoV-2 test was 244 days (IQR, 169–303 days).

Table 2 Effectiveness of previous infection against symptomatic reinfection

Subgroup analyses for both unvaccinated and vaccinated individuals yielded results similar to those of the main analysis (Table 3a and Extended Data Fig. 4a). The sensitivity analysis using a 40-day window21 for defining reinfection instead of the 90-day window also produced results consistent with the main analysis (Extended Data Table 2a).

Table 3 Effectiveness of previous infection against reinfection by vaccination status

The overall effectiveness of a pre-Omicron infection in preventing severe, critical or fatal COVID-19 on reinfection with a pre-Omicron virus was 98.0% (95% CI, 96.1–99.0%), with no observed waning over time after the previous infection (Table 1b and Fig. 1b).

Immune protection in the Omicron era

The overall effectiveness of an Omicron infection in preventing reinfection, regardless of symptoms, with an Omicron virus was estimated at 53.6% (95% CI, 52.1–55.0%) (Table 1c and Fig. 1a). The median duration between the previous infection and the study SARS-CoV-2 test was 245 days (IQR, 191–311 days).

This effectiveness demonstrated a rapid decline over time after the previous infection, decreasing from 81.3% (95% CI, 79.6–82.9%) within 3 to less than 6 months after the previous infection to 59.8% (95% CI, 57.8–61.7%) in the subsequent 3 months, and further dropping to 27.5% (95% CI, 22.7–32.0%) in the subsequent 3 months (Table 1c and Fig. 1a). Ultimately, it reached a negligible level after 1 year. The effectiveness was 59.5% (95% CI, 58.0–60.9%) in the first year after the previous infection and 4.8% (95% CI, −2.7–11.8%) thereafter.

The effectiveness of an Omicron infection in preventing symptomatic reinfection with an Omicron virus demonstrated a similar pattern to that observed for any reinfection (Table 2b). The overall effectiveness against symptomatic reinfection was 45.4% (95% CI, 42.5–48.2%), with a rapid decline observed over time after the previous infection. The median duration between the previous infection and the study SARS-CoV-2 test was 301 days (IQR, 225–457 days).

Subgroup analyses for both unvaccinated and vaccinated individuals yielded results similar to those of the main analysis (Table 3b and Extended Data Fig. 4b). The sensitivity analysis using a 40-day window21 for defining reinfection instead of the 90-day window also produced results consistent with the main analysis (Extended Data Table 2b).

The overall effectiveness of an Omicron infection in preventing severe, critical or fatal COVID-19 on reinfection with an Omicron virus was 100% (95% CI, 79.9–100%), with no cases of reinfection progressing to severe, critical or fatal COVID-19 (Table 1d). There was no evidence for a waning in this effectiveness over time after the previous infection (Fig. 1b).

Further validation analyses

Previous infection misclassification

Under-ascertainment of infection leads to misclassification of previous infection status in the test-negative design used in this study, potentially biasing the estimates15. Extended Data Figure 5 presents the results of mathematical modelling simulations that evaluated the impact of extreme under-ascertainment (90% of SARS-CoV-2 infections are undocumented) on the estimated waning pattern of immune protection during the pre-Omicron and Omicron eras.

The estimated effectiveness in presence of this bias, in both pre-Omicron and Omicron eras, was comparable to, but slightly lower than, the true effectiveness (Extended Data Fig. 5). This underestimation was larger in the Omicron analysis. However, in both analyses, this bias did not affect the estimated duration of immune protection, which is the central focus of our study.

Coexisting conditions misclassification

Coexisting conditions were identified by analysing electronic health record encounters within the national public healthcare system’s database (Supplementary Methods section 1). However, this approach may not capture all conditions, as some may be undiagnosed or diagnosed at private facilities.

The sensitivity analysis, which removed matching by the number of coexisting conditions to simulate a scenario of complete under-ascertainment, showed results nearly identical to the main analysis across the various estimates (Extended Data Figs. 6 and 7). This consistency was observed for both the pre-Omicron and Omicron eras, including overall effectiveness against any infection and against infection in both unvaccinated and vaccinated individuals, as well as effectiveness against severe, critical or fatal COVID-19 on reinfection, and effectiveness over time after the previous infection.

Validation using a cohort study design

This study was conducted using the test-negative design15. To validate the findings, two national, matched, retrospective cohort studies were also conducted: one for the pre-Omicron era and one for the Omicron era.

The estimates from both the test-negative study design and the cohort study design were consistent across the various outcomes in both the pre-Omicron and Omicron eras (Extended Data Figs. 8 and 9). These outcomes included overall effectiveness against any infection and against infection in both unvaccinated and vaccinated individuals, as well as effectiveness against severe, critical or fatal COVID-19 on reinfection, and effectiveness over time after the previous infection. Whereas the test-negative design yielded lower estimates overall, particularly in the Omicron analysis, both study designs produced similar results for the duration of immune protection, validating the findings of the test-negative design.

Discussion

The results show two distinct patterns in the protective effect of natural infection against reinfection in the Omicron era compared to the pre-Omicron era. Before the emergence of Omicron, natural infection offered robust protection against reinfection, with roughly 80% effectiveness and minimal signs of waning over time after the infection. However, during the Omicron era, this protection was strong only for recently infected individuals, rapidly declining over time after the infection and ultimately diminishing within a year. These patterns were consistent regardless of whether any infection or only symptomatic infection was considered as an outcome, and for both vaccinated and unvaccinated populations.

The two distinct patterns observed in the Omicron versus pre-Omicron eras provide population-level results that validate previous experimental molecular evidence1,2,18,19,20, and are probably the result of a complex interplay of several interrelated factors, in addition to waning immunity, immune evasion and the accelerated and convergent evolution of Omicron, such as immune imprinting, varying immunogenicity, global population immunity faced by the strains and population characteristics associated with infections at different stages of the pandemic.

Whereas these factors are interconnected and challenging to disentangle, the observed differences in protection against reinfection may stem from distinct evolutionary pressures acting on SARS-CoV-2 during the pre-Omicron and Omicron eras. In the pre-Omicron era, with a large proportion of individuals remaining immune naive because of non-pharmaceutical interventions and delayed scale-up of vaccination, intrinsic transmissibility may have been the primary driver of viral adaptation. This was evidenced by the emergence of more transmissible variants such as Alpha4,22,23 and Delta24,25. Conversely, following the very large and widespread Omicron wave in early 2022 (Extended Data Fig. 3)26, most individuals possessed some level of immunity, either from infection or vaccination. This may have shifted the dominant evolutionary pressure towards immune escape through not only antigenic drift, but also recombination and convergent evolution as the adaptive mechanisms for the virus2,18,27,28.

This shift in evolutionary pressure can explain the observed rapid decline in natural immunity protection against reinfection in the Omicron era and suggests an accelerated evolution of SARS-CoV-2 towards enhanced immune evasion in the current stage of the pandemic. The extent to which these findings describe an ecological survival strategy for novel respiratory viruses capable of rapid mutation, such as RNA viruses, as they transition from emergence to endemicity remains unknown, as does the relevance of these findings to other circulating respiratory viruses.

Immune imprinting, the memory recall behaviour of the immune system, in which the outcome is influenced by the antigenic distance between the ancestral strain and the variant27,29,30,31,32, may also help to explain these findings. This phenomenon, in which the specific sequence of immunological events can either enhance or compromise future immune responses to variant infections, may shape the diversity of polyclonal neutralizing antibodies elicited by Omicron breakthrough infections, potentially contributing to the observed patterns27,29,30,31,32,33.

An important finding is the robust and durable protection against severe COVID-19 on reinfection in both pre-Omicron and Omicron eras, with no observed waning in this protection. This distinct pattern suggests the involvement of different immune system components in protecting against non-severe versus severe reinfection. Whereas humoral immunity, mediated by neutralizing antibodies that block viral entry34,35, is the primary driver of protection against non-severe reinfection, it faces intense pressure from viral evolution towards immune escape. Conversely, protection against severe reinfection seems strongly influenced by cellular immunity through memory T cells36,37,38, which appears to be largely conserved37,38, perhaps indicating limited pressure on cellular immunity from the evolutionary forces driving immune escape.

Both vaccinated and unvaccinated populations showed similar contrasting patterns of protection between the pre-Omicron and Omicron eras (Extended Data Fig. 4). However, small quantitative differences in effectiveness were observed between these groups. These differences might be attributed to variations in the distribution of time intervals between the previous infection and the study test, a consequence of the changing dynamics of infection waves and vaccination scale-up over time. Previous studies suggest that immune imprinting effects might also have a role in explaining these differences11,12,30, but further investigation is needed to clarify these patterns.

Our findings at this stage of the pandemic corroborate earlier observations, demonstrating the consistently reduced severity of reinfections compared to primary infections9,14,39, even when both involve the Omicron variant. The results also confirm the strong protective effect of pre-Omicron immunity against pre-Omicron virus4,7,8,9,10,40,41. Furthermore, they highlight an association between viral immune evasion and accelerated waning of immune protection. This accelerated waning was previously observed in the rapid decline of pre-Omicron immunity, induced by both vaccination or natural infection, against the Omicron variant on its emergence14,42,43,44,45. Collectively, these findings suggest that immune evasion and subsequent rapid waning of immunity hinder the development of long-term population immunity to SARS-CoV-2, potentially leading to periodic waves of infection46, similar to those observed for common-cold coronaviruses47,48 and influenza49,50.

This study has limitations. The study is based on documented SARS-CoV-2 infections, but many infections may not have been documented, especially since the reduction in testing starting from 1 November 2022. However, this under-documentation of infection, a source of misclassification bias of previous infection status, may not have appreciably affected our findings based on our earlier analysis of the test-negative design methodology15. It should not have affected the estimated duration of immune protection, as demonstrated in the extra mathematical modelling analyses conducted in this study (Extended Data Fig. 5).

Depletion of the primary-infection cohort within the population owing to COVID-19 mortality at the time of primary infection can skew this cohort towards healthier individuals51. This skew could potentially lead to an overestimation of the effectiveness of infection in preventing severe, critical or fatal COVID-19 on reinfection. Nevertheless, given the low COVID-19 mortality rate in Qatar’s predominantly young population (less than 0.1% of primary infections)26,52,53, a survival effect is not likely to appreciably alter the observed high effectiveness of previous infection in mitigating the severity of reinfection.

In the sensitivity analysis using a 40-day time window to define reinfection, as opposed to the conventional 90-day time window21 (Extended Data Table 2), estimates for both overall protection and protection lasting less than 1 year showed a slight bias towards lower values. This bias stemmed from the inclusion of SARS-CoV-2 tests conducted between 40 and 90 days post-initial infection. Tests within this timeframe captured sporadic positive PCR results that did not signify genuine reinfections but rather reflected instances in which the initial infection persisted beyond 40 days or in which PCR positivity persisted because of residual non-viable viral fragments54. This source of bias, however, should not affect other estimates in this study as it is very rare for such false reinfections to occur after 90 days post-initial infection21.

A consequence of the test-negative design is that effectiveness estimates depend on the timing of the tests, specifically the interval between the previous infection and the SARS-CoV-2 test used in the study15. This can lead to seemingly contradictory results that are not necessarily indicative of true discrepancies. For instance, in the Omicron era analysis, the effectiveness against any reinfection (53.6%) was higher than that against symptomatic reinfection (45.4%). This might seem counterintuitive, as protection against symptomatic illness is typically expected to be higher55. However, this apparent discrepancy can be explained by the differential timing between the previous infection and the study test. The median time between the previous infection and the study test was 245 days for the analysis of any reinfection, whereas it was longer at 301 days for the analysis of symptomatic reinfection. This longer interval in the latter analysis resulted in greater waning of immune protection, leading to the observed difference in effectiveness estimates.

With the relatively young population of Qatar17, our findings may not be generalizable to other countries in which older citizens constitute a large proportion of the population. Whereas robust matching was implemented, the availability of data prevented matching on other factors such as geography or occupation. However, being essentially a city state, infection incidence in Qatar was broadly distributed across neighbourhoods. Nationality, age and sex provide a powerful proxy for socioeconomic status in this country17, and thus matching by these factors may have also, at least partially, controlled for other factors such as occupation. This matching approach has been previously investigated in studies of different epidemiologic designs, and using control groups to test for null effects56,57,58,59. These studies have supported that this matching prescription effectively controls for differences in infection exposure56,57,58,59.

However, bias in real-world data can arise unexpectedly or from unknown sources, such as subtle differences in test-seeking behaviour, changes in testing patterns because of policy shifts, variations in test accessibility or differences in the tendency to get tested between individuals who have recovered from a previous infection and those who have not been infected or whose previous infection was undocumented. Nevertheless, the further analyses investigating the impact of different sources of bias and the replication of the entire study using a different study design—a cohort study—confirmed and validated the findings.

This study has strengths. First, it was conducted on a national scale, encompassing a diverse population based on national backgrounds, and used extensive and validated databases established through numerous SARS-CoV-2 infection studies. Second, controls were selected from the entire national population, and exact matching was used to ensure rigorous pairing of cases and controls. Third, the study design controlled for vaccination status, another strength of the test-negative design, allowing for differentiation between the effects of previous infection and vaccination. Effectiveness estimates were also obtained for both unvaccinated and vaccinated populations, and the results of these analyses were consistent with each other and with the main analysis for the entire population. Fourth, using distinct reinfection window definitions of 90 versus 40 days resulted in considerably different analysis datasets. Yet, the effectiveness estimates remained consistent across these varying criteria. Finally, the findings were corroborated through further analyses and by a complete replication using a distinct epidemiological study design.

In conclusion, a stark contrast is found in the protective effect of natural infection against SARS-CoV-2 reinfection between the pre-Omicron and Omicron eras. Before Omicron emergence, natural infection provided robust and enduring protection against reinfection. However, during the Omicron era, this protection was strong only among recently infected individuals, rapidly declining and diminishing within 1 year. These contrasting patterns may suggest differing evolutionary pressures acting on the virus. In the pre-Omicron era, intrinsic transmissibility drove viral adaptation, whereas the widespread immunity acquired by the end of the first Omicron wave shifted the evolutionary pressure towards immune escape. This highlights the dynamic interplay between viral evolution and host immunity, necessitating continued monitoring of the virus and its evolution, as well as periodic updates of SARS-CoV-2 vaccines to restore immunity and counter continuing viral immune evasion.

Methods

Oversight

The institutional review boards at Hamad Medical Corporation and Weill Cornell Medicine–Qatar approved this retrospective study with a waiver of informed consent. The study was reported according to the Strengthening the Reporting of Observational Studies in Epidemiology (STROBE) guidelines (Extended Data Table 3).

Study population and data sources

This study was conducted on the population of Qatar before and after the introduction of the Omicron variant on 19 December 2021 (ref. 16). The first analysis assessed the effectiveness of pre-Omicron infection in preventing reinfection with a pre-Omicron virus between 5 February 2020 (the onset of the COVID-19 pandemic in Qatar17) and 18 December 2021. The second analysis assessed the effectiveness of Omicron infection in preventing reinfection with an Omicron virus between 19 December 2021 and 12 February 2024 (marking the end of the study).

The data encompassed the national, federated databases for COVID-19 laboratory testing, vaccination, hospitalization and death, retrieved from the integrated, nationwide, digital-health information platform (Supplementary Methods section 2). These databases have captured SARS-CoV-2-related data with no missing information since the onset of the pandemic, including all PCR tests regardless of location or facility, and, from 5 January 2022, all medically supervised rapid antigen tests (Supplementary Methods section 3). SARS-CoV-2 testing was extensive in Qatar until 31 October 2022, with nearly 5% of the population being tested every week, primarily for routine purposes such as screening or meeting travel-related requirements56,60. Subsequently, testing rates decreased, with less than 1% of the population being tested per week61. Most infections during the pandemic were diagnosed through routine testing rather than symptomatic presentation56,60.

Qatar launched its COVID-19 vaccination programme in December 2020, using messenger RNA vaccines and prioritizing individuals on the basis of coexisting conditions and age criteria56,59. COVID-19 vaccination was provided free of charge, regardless of citizenship or residency status, and was nationally tracked56,59. Demographic information, including sex, age and nationality, was extracted from the records of the national health registry. Qatar shows demographic diversity, with 89% of its residents being expatriates from more than 150 countries17. Detailed descriptions of Qatar’s population and national databases have been previously reported17,32,51,53,56,60,62.

Study design

The effectiveness of natural infection against reinfection was estimated using the test-negative, case-control study design, which compares the odds of previous infection among SARS-CoV-2-positive tests (cases) to that among SARS-CoV-2-negative tests (controls)11,12,15,16,63,64. The assessment was conducted both overall and by time since previous infection, using 3-month intervals.

Cases and controls were determined on the basis of the results of SARS-CoV-2 tests conducted during each analysis period. Cases were defined as SARS-CoV-2-positive tests, whereas controls were defined as SARS-CoV-2-negative tests. SARS-CoV-2 reinfection is conventionally defined as a documented infection more than or equal to 90 days after a previous infection, to avoid misclassifying prolonged test positivity as reinfection with shorter time intervals16,21,65,66. Consequently, cases or controls preceded by SARS-CoV-2-positive tests within 90 days were excluded. Previous infection was defined as a SARS-CoV-2-positive test more than or equal to 90 days before the study test.

To comply with the non-differential healthcare-seeking behaviour assumption inherent to the test-negative study design15,63,64, only tests with a documented reason for testing were included in the analysis. In the Omicron era analysis, cases or controls preceded by a pre-Omicron infection were excluded from the analysis, as the research question pertained to the effectiveness of Omicron immunity, rather than pre-Omicron immunity, against Omicron reinfection. The protection provided by pre-Omicron immunity against Omicron reinfection has been previously investigated14,16,60.

In estimating effectiveness in preventing reinfection, cases and controls were matched exactly one-to-two by sex, 10-year age group, nationality, number of coexisting conditions (ranging from zero to more than or equal to six; Supplementary Methods section 1), number of vaccine doses (ranging from zero to more than or equal to four), calendar week of the SARS-CoV-2 test, method of testing (PCR or rapid antigen) and reason for testing. This matching strategy aimed to balance observed confounders that could potentially influence the risk of infection across the exposure groups17,67,68,69,70. The selection of matching factors was guided by findings from earlier studies on Qatar’s population11,56,57,58,59,71 and the need to comply with the non-differential healthcare-seeking behaviour assumption inherent to the test-negative design15,63,64. This requirement was met by matching by the calendar week of the SARS-CoV-2 test, method of testing and reason for testing. In estimating effectiveness in preventing severe72, critical72 or fatal73 COVID-19 on reinfection, a one-to-five matching ratio was applied to enhance statistical precision.

Classification of severe72, critical72 and fatal73 COVID-19 followed the World Health Organization guidelines (Supplementary Methods section 4). The assessments were made by trained medical personnel independent of study investigators and using individual chart reviews. As part of the national protocol, each individual who had a SARS-CoV-2-positive test and concurrent COVID-19 hospital admission was subject to an infection severity assessment every 3 days until discharge or death, irrespective of hospital length of stay26. Individuals who progressed to severe, critical or fatal COVID-19 between the SARS-CoV-2-positive test and the end of this study were classified on the basis of their worst outcome, starting with death, followed by critical disease and then severe disease.

The variant status of infections was determined on the basis of the dominant variant at the time of infection diagnosis. Infections were categorized as pre-Omicron or Omicron. The duration of dominance for every variant throughout the pandemic was determined using Qatar’s variant genomic surveillance74,75,76 (Extended Data Fig. 3), which includes viral genome sequencing74 and multiplex real-time quantitative PCR with reverse transcription (RT–qPCR) variant screening75 of weekly collected random positive clinical samples (Supplementary Methods section 3). Once the first massive Omicron wave started, virtually all infections were due to Omicron, as it displaced all pre-Omicron variants16,60,62.

Statistical analysis

All records of SARS-CoV-2 testing were examined for the selection of cases and controls, but only matched samples were analysed. Cases and controls were described using frequency distributions and measures of central tendency and compared using standardized mean differences. A standardized mean difference of less than or equal to 0.1 indicated adequate matching77.

Odds ratios (ORs), comparing odds of previous infection among cases versus controls, and associated 95% CIs were derived using conditional logistic regression. Analyses stratified by time since previous infection considered the date for the most recent documented infection. CIs were not adjusted for multiplicity and interactions were not investigated. The reference group for all estimates comprised individuals with no documented previous infection.

Effectiveness measures and associated 95% CIs were calculated as 1-OR of previous infection among cases versus controls if the OR was less than one, and as 1/OR-1 if the OR was more than or equal to one (refs. 15,32,63,78). This approach ensured a symmetric scale for both negative and positive effectiveness, spanning from −100 to 100%, resulting in a clear and meaningful interpretation of effectiveness, regardless of the value being positive or negative.

In addition to estimating effectiveness of previous infection in preventing reinfection, regardless of symptoms, effectiveness was also assessed specifically against symptomatic reinfection. This was accomplished by restricting the analysis to tests performed owing to clinical suspicion, indicating the presence of symptoms consistent with a respiratory tract infection.

Subgroup analyses were performed, considering only unvaccinated and vaccinated individuals, respectively. A sensitivity analysis was undertaken by redefining SARS-CoV-2 reinfection as a documented infection occurring more than or equal to 40 days after a previous infection, instead of the conventional more than or equal to 90 days. This adjustment was informed by a recent analysis suggesting the adequacy of a 40-day time window to define reinfection21. Statistical analyses were conducted in STATA/SE version v.18.0 (Stata).

Further validation analyses

Previous infection misclassification

Under-ascertainment of infection introduces misclassification of previous infection status into the test-negative design used in this study, potentially biasing the estimates15. To assess the impact of under-ascertainment on estimates of waning immune protection, mathematical modelling simulations were conducted by extending our previous work on the test-negative design methodology15. These simulations evaluated the impact of an infection ascertainment rate of only 10%, indicating that 90% of SARS-CoV-2 infections are undocumented and would thus be misclassified. The model incorporated a gradual (linear) waning of the protective effect of infection against reinfection. Analyses were performed for both pre-Omicron and Omicron waning patterns, with immune protection durations set at 3 years for the pre-Omicron era14 and 1 year for the Omicron era. The results were reported at the 2-year mark from the onset of both the pre-Omicron and Omicron pandemic phases. A detailed description of the model, its methods and previous analyses can be found elsewhere15.

Coexisting conditions misclassification

Coexisting conditions were identified by analysing electronic health record encounters for each individual within the national public healthcare system’s database (Supplementary Methods section 1). However, this approach may not capture all conditions, as some may be undiagnosed or diagnosed at private facilities with unavailable records. To assess the impact of this potential bias on the estimated effectiveness of infection against reinfection, a sensitivity analysis was conducted in which matching by the number of coexisting conditions was entirely removed, simulating a scenario of complete under-ascertainment of these conditions.

Validation using a cohort study design

This study used the test-negative design15. To validate the findings, two extra national, matched, retrospective cohort studies—one for the pre-Omicron era and another for the Omicron era—were conducted. Each study compared the incidence of infection and severe forms of COVID-19 in two national cohorts: individuals with documented primary SARS-CoV-2 infection (primary-infection cohort) and uninfected individuals (uninfected cohort).

The first study estimated the effectiveness of a pre-Omicron primary infection in preventing reinfection with a pre-Omicron virus, and the second study estimated the effectiveness of an Omicron primary infection in preventing reinfection with an Omicron virus. Both studies were conducted over the same study durations as in the main analysis using the test-negative design. Incidence of infection was defined as any PCR-positive or rapid antigen-positive test after the start of follow-up, irrespective of symptomatic presentation.

Cohorts were matched exactly one-to-one by sex, 10-year age group, nationality, number of coexisting conditions, number of vaccine doses at the start of the follow-up, calendar week of the SARS-CoV-2-positive test for the primary-infection cohort and SARS-CoV-2-negative test for the uninfected cohort, method of testing (PCR or rapid antigen) and reason for testing. In both studies, individuals in the matched primary-infection cohort may have contributed follow-up time in the uninfected cohort before their primary infection and subsequently contributed follow-up time as part of the primary-infection cohort after contracting the infection.

Follow-up for each matched pair started 90 days after the primary infection for the individual in the primary-infection cohort. To ensure exchangeability, both members of each matched pair were censored at the earliest occurrence of receiving an extra vaccine dose. Accordingly, individuals were followed until the first of any of the following events: a documented SARS-CoV-2 infection, a new vaccine dose for the individual in either the primary-infection cohort or the uninfected cohort (with matched-pair censoring), death or the administrative end of follow-up, which was set at the end of the study or 15 months after the primary infection, whichever came first.

The overall adjusted hazard ratio (aHR), comparing the incidence of SARS-CoV-2 infection (or severe forms of COVID-19) between the cohorts, and the corresponding 95% CI, were calculated using Cox regression models with adjustment for the matching factors and testing rate in the cohorts, using the Stata v.18.0 stcox command. This adjustment was implemented to ensure precise and unbiased estimation of the standard variance79.

The overall aHR provides a weighted average of the time-varying hazard ratio80. To explore differences in the risk of infection (or severe forms of COVID-19) over time, the aHR was also estimated by 3-month intervals from the start of follow-up using separate Cox regressions, with ‘failure’ restricted to specific time intervals.

Effectiveness of infection against reinfection and against severe, critical or fatal COVID-19, along with the associated 95% CIs, were derived from the aHR as 1-aHR if the aHR was less than one and as 1/aHR-1 if the aHR was more than or equal to one (refs. 32,78). This approach ensured a symmetric scale for both negative and positive effectiveness, spanning from −100 to 100%, resulting in a meaningful interpretation of effectiveness, regardless of the value being positive or negative.

Statistical analyses were performed using Stata/SE v.18.0 (Stata). Further details on this type of cohort study design can be found in our previous publications, which used also the same national databases to estimate the effectiveness of infection against reinfection or the effectiveness of vaccination against infection4,8,10,14,15,30,32,33,45,59,61,62,71,81,82,83.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.