Molnupiravir and nirmatrelvir-ritonavir have emerged as promising options for COVID-19 treatment, but direct comparisons of their effectiveness have been limited. This study aimed to compare the effectiveness of these two oral antiviral drugs in non-hospitalised and hospitalised patients with COVID-19. In this target trial emulation study, we used data from a territory-wide electronic health records database on eligible patients aged ≥18 years infected with COVID-19 who were prescribed either molnupiravir or nirmatrelvir-ritonavir within five days of infection between 16 March 2022 and 31 December 2022 in the non-hospitalised and hospitalised settings in Hong Kong. A sequence trial approach and 1:1 propensity score matching was applied based on age, sex, number of COVID-19 vaccine doses received, Charlson comorbidity index, comorbidities, and drug use within past 90 days. Cox regression adjusted with patients' characteristics was used to compare the risk of effectiveness outcomes (all-cause mortality, intensive care unit (ICU) admission or ventilatory support and hospitalisation) between groups. Subgroup analyses included age (<70; ≥70 years); sex, Charlson comorbidity index (<4; ≥4), and number of COVID-19 vaccine doses received (0-1; ≥2 doses). A total of 63,522 non-hospitalised (nirmatrelvir-ritonavir: 31,761; molnupiravir: 31,761) and 11,784 hospitalised (nirmatrelvir-ritonavir: 5892; molnupiravir: 5892) patients were included. In non-hospitalised setting, 336 events of all-cause mortality (nirmatrelvir-ritonavir: 71, 0.22%; molnupiravir: 265, 0.83%), 162 events of ICU admission or ventilatory support (nirmatrelvir-ritonavir: 71, 0.22%; molnupiravir: 91, 0.29%), and 4890 events of hospitalisation (nirmatrelvir-ritonavir: 1853, 5.83%; molnupiravir: 3037, 9.56%) were observed. Lower risks of all-cause mortality (absolute risk reduction (ARR) at 28 days: 0.61%, 95% CI: 0.50-0.72; HR: 0.43, 95% CI: 0.33-0.56) and hospital admission (ARR at 28 days: 3.73%, 95% CI: 3.31-4.14; HR: 0.72, 95% CI: 0.67-0.76) were observed in nirmatrelvir-ritonavir users compared to molnupiravir users. In hospitalised setting, 509 events of all-cause mortality (nirmatrelvir-ritonavir: 176, 2.99%; molnupiravir: 333, 5.65%), and 50 events of ICU admission or ventilatory support (nirmatrelvir-ritonavir: 26, 0.44%; molnupiravir: 24, 0.41%) were observed. Risk of all-cause mortality was lower for nirmatrelvir-ritonavir users than for molnupiravir users (ARR at 28 days: 2.66%, 95% CI: 1.93-3.40; HR: 0.59, 95% CI: 0.49-0.71). In both settings, there was no difference in the risk of intensive care unit admission or ventilatory support between groups. The findings were consistent across all subgroup's analyses. Our analyses suggest that nirmatrelvir-ritonavir was more effective than molnupiravir in reducing the risk of all-cause mortality in both non-hospitalised and hospitalised patients. When neither drug is contraindicated, nirmatrelvir-ritonavir may be considered the more effective option. HMRF Research on COVID-19, The Hong Kong Special Administrative Region (HKSAR) Government; Collaborative Research Fund, University Grants Committee, the HKSAR Government; and Research Grant from the Food and Health Bureau, the HKSAR Government; the Laboratory of Data Discovery for Health (D24H) funded by the AIR@InnoHK administered by Innovation and Technology Commission.