Jesus, a 40-year-old inmate in Leon prison in northern Spain, said he lost the will to live after his girlfriend died last month.
It was the intervention of four of his fellow prisoners who may have prevented his suicide, "guardian angels" who watched over him day and night, sleeping in the second bed in his narrow cell.
"Sometimes, their mere presence made me feel better," said Jesus, who is serving a 30-month sentence for armed robbery. "I don't know if, without them, I would have killed myself, but I had that idea in my head."
The "angels" are part of a four-year-old nationwide programme aimed at preventing prison suicides, in which prisoners are trained by psychologists to watch over any of their fellow inmates who appear to be at risk.
The programme is credited with cutting the number of prison suicides in Spain from 40 in 2004 to 19 last year.
And several countries have expressed interest in copying it.
At Leon prison "we have had no suicides for almost four years, while previously the annual average was two per year," said prison director Jose Manuel Cendon.
The facility, which houses about 1,800 inmates including some 100 women, has around 20 inmates in the programme, trained to listen attentively to their charges and watch for the slightest change in mood.
"We need motivated people who display great self-control, good listening skills and the ability to forge an emotional connection with the inmate in need," said Goyo Jular, a prison psychologist.
"Their work is vital as they are with them constantly, they provide constant monitoring."
They also learn the basics of first aid "just in case", said one the "angels", Juan, 43, who is serving 10 years for drug trafficking.
He takes his job very seriously.
"We try to make them live with us in the same cell, where they open up more, it helps to communicate with them," he said. "We do everything we can to help them forget their problems."
According to the psychologist Jular, the "angels" themselves also gain from the experience.
"They gain recognition and it helps them carry out their sentence in a positive way," as well as sometimes winning them benefits and remission.
The prison managers are now considering adapting the programme for its units housing dangerous inmates.
For Jose Maria, who for several months was withdrawn and depressed, the "angels" are a "gift from heaven".
"When I came to prison I needed a guardian angel because I had never set foot in a prison before. I committed a reprehensible crime and the guilt was enormous," the inmate, who is serving 25 years for murder, said timidly.