Abstract This study aimed to study the risk of SARS-CoV-2 infection and severe COVID-19 outcomes across different mental diagnoses and to assess the role of sex in these associations. We used electronic health records from Catalonia to identify adults receiving inpatient/outpatient mental health care between 2017-2019 with diagnosis of non-affective psychosis (NAP), bipolar disorder (BD), depressive disorder (DEP), stress-related disorders, neurotic/somatoform disorders (NSD), and substance misuse (SUB) (exposed). Outcomes included SARS-CoV-2 infection, COVID-19 hospitalization, and COVID-19-related death. Adjusted logistic regression analyses were conducted. 785,378 adults were included (70.3% < 65 years old; 57.1% women). Compared to unexposed, those with NAP [OR (95%CI): 0.84 (0.80-0.88)], BD [0.80 (0.75-0.86)], DEP [0.97 (0.94-1.00)] and SUB [0.81 (0.78-0.84)] had a lower risk of SARS-CoV-2 infection, while people with NSD presented an increased risk [1.03 (1.01-1.06)]. Among those infected, people with DEP, NSD, and SUB had a lower risk of COVID-19 hospitalization, but higher risk of COVID-19-related death [1.23 (1.07-1.41); 1.26 (1.07-1.48); 1.48 (1.24-1.71), respectively]. A higher COVID-19-related death was also found in people with NAP and BD [1.68 (1.34-2.12); 2.02 (1.50-2.73)]. Sex-stratified analysis showed that women with NSD were especially vulnerable to infection [1.07 (1.03-1.11)], and women with DEP and NSD to COVID-19-related death [1.24 (1.05-1.47); 1.26 (1.02-1.54)]. These results suggest different vulnerabilities to infection and COVID-19 hospitalization and death across mental disorders. These findings have implications for pandemic preparedness, highlighting the need for specific public health strategies to mitigate the excess of mortality of people with certain mental disorders.