Nicholas Feliciano was hauled into a holding pen at Rikers Island on the night before Thanksgiving, after a brawl broke out among detainees at the jail. His lip had been gashed and his friend Alfonso Martinez had been stabbed.

As Mr. Martinez was being taken to an infirmary, he recalled his friend saying, “If they separate us, I’m going to kill myself.” It was no idle threat. Mr. Feliciano, 18, had tried to take his own life several times before, most recently at a juvenile detention center, his grandmother, Madeline Feliciano, said.

Hours later, alone in the pen, Mr. Feliciano twisted a piece of clothing into a noose and tried to hang himself from a U-shaped piece of metal bolted to the ceiling above a toilet. The piece of metal had been left there even though it had been used six days earlier in another suicide attempt, two people with knowledge of the episode said.

For seven minutes, guards looked in on Mr. Feliciano while he tried to hang himself, but did not enter the cell. Mr. Martinez, who had been wheeled into the area on a gurney after receiving medical treatment, said he shouted at the guards, “He’s hanging!”