Background: Although most children and adolescents have had a previous SARS-CoV-2 infection and many continue to receive COVID-19 vaccinations, studies of the effectiveness of hybrid immunity against reinfection with the omicron (B.1.1.529) variant are scarce. We aimed to examine the effectiveness of vaccination in convalescent children and adolescents against reinfection with the delta (B.1.617.2) variant and the BA.1 and BA.2 and BA.4 and BA.5 omicron subvariants. Methods: This retrospective cohort study was devised to emulate a target randomised control trial using a retrospective dataset of anonymised health records of children (5–11 years old) and adolescents (12–16 years old) who were members of the Maccabi Healthcare Services, Israel. The design emulated 91 randomised trials by devising a series of multiple nested trials, compiling the results into a single dataset, and fitting Cox proportional hazards models to estimate adjusted hazard ratios (HRs) with 95% CIs of each measured outcome. The primary aim was to assess the protection from reinfection with the delta variant and the BA.1 and BA.2 and BA.4 and BA.5 omicron subvariants associated with hybrid immunity as a result of a previous SARS-CoV-2 infection followed by vaccination with the BNT162b2 (Pfizer–BioNTech) vaccine. Findings: Data from between from March 1, 2020, to July 31, 2022, for 163 812 individuals (120 721 children [59 404 girls and 61 317 boys], median age 8·0 years [IQR 6·7 to 10·2]; and 43 091 adolescents [21 239 girls and 21 852 boys], median age 13·5 years [12·6 to 14·8]) were included in at least one trial. A single dose of the BNT162b2 vaccine in convalescent children and adolescents confers statistically significant protection against the delta variant (78% [95% CI 72 to 83] in adolescents and 64% [3 to 87] in children) and the omicron BA.1 and BA.2 subvariants (54% [50 to 57] in adolescents and 71% [67 to 73] in children) compared with children who had a previous infection but were unvaccinated. However, the vaccine was not found to confer statistically significant protection against the BA.4 and BA.5 omicron subvariants in adolescents (8% [–18 to 29]) and children (12% [–6 to 27]). Interpretation: Decision makers in BA.4 and BA.5 dominant regions should re-examine whether convalescent individuals aged 5–16 years should receive the BNT162b2 vaccine to prevent future reinfection, especially in light of reports that show that most children and adolescents have already been infected with SARS-CoV-2. Funding: None.