The COVID-19 pandemic has been extensively discussed in the context of its effect on mental health. Although global suicide rates have remained stable during the pandemic, the specific effect on non-fatal suicide behaviours during and after the pandemic remains underexplored. This study aims to investigate patterns of non-fatal suicide behaviours before, during, and after the pandemic. In this cohort study, we used data from all hospitals in Catalonia, Spain, collected through the Catalan Suicide Risk Code, which is a specifically designed suicide attempt surveillance protocol, involving a face-to-face, in-depth psychiatric evaluation, after a Catalan resident presents any suicide risk behaviour in any public health-care setting. This evaluation centralises data from suicide registries across the territory. We included non-fatal suicide behaviours, meaning suicidal ideation or attempts that did not result in death, and excluded self-harm behaviours not judged to be linked with suicidal ideation. We considered three periods: the pre-confinement period (Jan 1, 2018, to the enforcement of the lockdown in Spain on March 14, 2020); the confinement period (March 14, 2020, to the end of lockdown on June 21, 2020); and the post-confinement period (June 21, 2020, to Dec 31, 2022). We used Bayesian structural time series models to assess the effect of pandemic phases on non-fatal suicide behaviours, and we ran stratified analyses by sex and age to identify distinct patterns among demographic cohorts. We obtained 26 482 records from Jan 1, 2018, to Dec 31, 2022. The mean age was 37·94 years (SD 18·07), and the sample included 17 584 (66·4%) women and 8898 (33·6%) men. Data on ethnicity were not collected. Temporal trends showed a mild increase in non-fatal suicide behaviours from Jan 1, 2018, to March 13, 2020; a reduction during the confinement period; and a subsequent rise after confinement. Bayesian models suggested a significant causal effect of lockdown easing, resulting in a 50·77% increase in non-fatal suicide behaviours (95% credible interval [CrI] 26·62-76·58; p<0·0001). Stratified analyses indicated that the easing of lockdown resulted in a significant increase in non-fatal suicide behaviours among women (25·92%; 6·71-44·72; p=0·011) and among individuals aged 18 years and younger (72·75%; 38·81-108·11; p<0·0001). This study provides a comprehensive examination of non-fatal suicide behaviours in Catalonia, Spain, emphasising the dynamics of different COVID-19 pandemic phases. The initial reduction during strict lockdown aligns with Joiner's Interpersonal Theory of Suicide, whereas the post-confinement rise reflects complex factors, including social isolation and economic challenges. Sex-specific and age-specific analyses underscore distinct vulnerabilities, emphasising the need for targeted preventive strategies. Centro de Investigación Biomédica en Red de Salud Mental annual budget of G21, Agència de Gestió d'Ajuts Universitaris i de Recerca of the Generalitat de Catalunya. For the Catalan and Spanish translations of the abstract see Supplementary Materials section.