Currently, real-world data on doravirine are scarce. In a national prospective cohort, we assessed the effectiveness and tolerability of switching to doravirine-based antiretroviral therapy (ART) in people with HIV. We did a nationwide, matched, prospective cohort study of people with HIV without previous virological failure and stable for at least 12 months on non-doravirine-containing triple or dual ART switching to doravirine before Sept 1, 2020 (exposed group). Participants in the exposed group were matched 1:2 to individuals continuing stable non-doravirine-containing ART, on age, sex, HIV acquisition category, time since ART initiation, calendar time, pre-ART CD4-count, pre-ART plasma viral load (PVL) and anchor drug class before switching. The primary outcome was protocol-defined virological failure (PDVF; PVL of ≥200 copies per mL) in the intention-to-treat (ITT) population at week 104, with participants modifying their regimen or becoming lost to follow-up considered as PDVF (non-inferiority margin +5%). In contrast, in the on-treatment population, those who modified their regimen or became lost to follow-up were censored from that moment onwards. Tolerability was a secondary outcome. In total, 590 participants in the exposed group and 1180 participants in the unexposed group (of whom 55·3% used integrase strand transfer inhibitor-based regimens) were included. In the ITT analysis, PDVF occurred in 135 (22·9%) exposed participants and in 295 (25·0%) unexposed participants (risk difference -2·12%, upper limit of the one-sided 95% CI +1·40%). In the on-treatment analysis, 10 (2·2%) of 455 non-censored exposed participants and 26 (2·9%) of 885 non-censored unexposed participants had PDVF (risk difference -0·70%, upper limit of the one-sided 95% CI +0·73%). All exposed participants with a PVL of 200 copies or more per mL resuppressed without regimen modification: no confirmed virological failure (two consecutive PVLs of ≥200 copies per mL) was observed. 104 (17·6%) exposed participants and 211 (17·9%) unexposed participants modified their regimen. 73 (12.4%) exposed participants discontinued doravirine due to adverse events: abnormal dreams (1·7%) and insomnia (1·5%) were most common. Switching to doravirine in well suppressed people with HIV without previous virological failure was non-inferior compared with continuing non-doravirine-containing regimens after 2 years in a real-world setting. None.