Few trials have compared homologous and heterologous third doses of COVID-19 vaccination with inactivated vaccines and mRNA vaccines. The aim of this study was to assess immune responses, safety, and efficacy against SARS-CoV-2 infection following homologous or heterologous third-dose COVID-19 vaccination with either one dose of CoronaVac (Sinovac Biotech; inactivated vaccine) or BNT162b2 (Fosun Pharma-BioNTech; mRNA vaccine). This is an ongoing, randomised, allocation-concealed, open-label, comparator-controlled trial in adults aged 18 years or older enrolled from the community in Hong Kong, who had received two doses of CoronaVac or BNT162b2 at least 6 months earlier. Participants were randomly assigned, using a computer-generated sequence, in a 1:1 ratio with allocation concealment to receive a (third) dose of CoronaVac or BNT162b2 (ancestral virus strain), stratified by types of previous COVID-19 vaccination (homologous two doses of CoronaVac or BNT162b2). Participants were unmasked to group allocation after vaccination. The primary endpoint was serum neutralising antibodies against the ancestral virus at day 28 after vaccination in each group, measured as plaque reduction neutralisation test (PRNT50) geometric mean titre (GMT). Surrogate virus neutralisation test (sVNT) mean inhibition percentage and PRNT50 titres against omicron BA.1 and BA.2 subvariants were also measured. Secondary endpoints included geometric mean fold rise (GMFR) in antibody titres; incidence of solicited local and systemic adverse events; IFNγ+ CD4+ and IFNγ+ CD8+ T-cell responses at days 7 and 28; and incidence of COVID-19. Within-group comparisons of boost in immunogenicity from baseline and between-group comparisons were done according to intervention received (ie, per protocol) by paired and unpaired t test, respectively, and cumulative incidence of infection was compared using Kaplan-Meier curves and a proportional hazards model to estimate hazard ratio. The trial is registered with ClinicalTrials.gov, NCT05057169. We enrolled participants from Nov 12, 2021, to Jan 27, 2022. We vaccinated 219 participants who previously received two doses of CoronaVac, including 101 randomly assigned to receive CoronaVac (CC-C) and 118 randomly assigned to receive BNT162b2 (CC-B) as their third dose; and 232 participants who previously received two doses of BNT162b2, including 118 randomly assigned to receive CoronaVac (BB-C) and 114 randomly assigned to receive BNT162b2 (BB-B) as their third dose. The PRNT50 GMTs on day 28 against ancestral virus were 109, 905, 92, and 816; against omicron BA.1 were 9, 75, 8, and 86; and against omicron BA.2 were 6, 80, 6, and 67 in the CC-C, CC-B, BB-C, and BB-B groups, respectively. Mean sVNT inhibition percentages on day 28 against ancestral virus were 83%, 96%, 87%, and 96%; against omicron BA.1 were 15%, 58%, 19%, and 69%; and against omicron BA.2 were 43%, 85%, 50%, and 90%, in the CC-C, CC-B, BB-C, and BB-B groups, respectively. Participants who had previously received two doses of CoronaVac and a BNT162b2 third dose had a GMFR of 12 (p<0·0001) compared with those who received a CoronaVac third dose; similarly, those who had received two doses of BNT162b2 and a BNT162b2 third dose had a GMFR of 8 (p<0·0001). No differences in CD4+ and CD8+ T-cell responses were observed between groups. We did not identify any vaccination-related hospitalisation within 1 month after vaccination. We identified 58 infections when omicron BA.2 was predominantly circulating, with cumulative incidence of 15·3% and 15·4% in the CC-C and CC-B groups, respectively (p=0·93), and 16·7% and 14·0% in the BB-C and BB-B groups, respectively (p=0·56). Similar levels of incidence of, presumably, omicron BA.2 infections were observed in each group despite very weak antibody responses to BA.2 in the recipients of a CoronaVac third dose. Further research is warranted to identify appropriate correlates of protection for inactivated COVID-19 vaccines. Health and Medical Research Fund, Hong Kong. For the Chinese translation of the abstract see Supplementary Materials section.