Purpose: Suicidal behaviour is a common in prisoners, yet little is known about the factors that may protect against thoughts of ending one's life. The purpose of this paper is to specify and test a structural model to examine the relationship between three criminal social identity (CSI) dimensions (in-group affect, in-group ties, and cognitive centrality) and suicide ideation while controlling for period of confinement, age, criminal friends, and offense type (violent vs non-violent). Design/methodology/approach: Participants were 415 male juvenile offenders incarcerated in prisons in Khyber Pakhtunkhwa Pakistan. A structural model was specified and tested using Mplus to examine the relationships between the three factors of CSI and suicidal thoughts, while controlling for age, offender type, period of confinement, and substance dependence. Findings: The model provided an adequate fit for the data, explaining 22 per cent of variance in suicidal thoughts. In-group affect (the level of personal bonding with other criminals) was found to exert a strong protective effect against suicide ideation. Originality/value: The research contributes important information on suicide ideation in Pakistan, an Islamic country in which suicide is considered a sin and subsequently a criminal offence. Results indicate that Juvenile offenders' sense of shared identity may help to prevent the development of thoughts of death by suicide. Consequently, separating and isolating young prisoners may be ill advised.