A spokesman for the mayor, Eric Phillips, did not respond directly to the accusations of abuse. In a statement, Mr. Phillips said, “For an extremely small number of young detainees facing credible safety threats in our jails, the safest option is a transfer to another facility.”

The Albany County Sheriff’s Office did not immediately respond to a request for comment.

The inmates’ situation was exacerbated when they were sent to solitary confinement, the suit claimed. Isolation increases the risk of depression or suicide, especially among younger inmates.

The city’s jail reforms were inspired, in part, Mr. de Blasio said, by Kalief Browder, a teenager who committed suicide after spending much of his three years at Rikers in solitary confinement before robbery charges against him were dropped.

Hundreds of inmates have been kept out of isolation since the city implemented its ban on solitary confinement for young people and reduced its use for other inmates. Still, the transfer of inmates to outside jails seems to highlight the limitations of the ban.

Two of the plaintiffs in the lawsuit were 19 and 21 when they were transferred to Albany. The other two were older than 22. One of the plaintiffs is identified only as John Doe because he fears retaliation by correction workers.

One of the plaintiffs, Davon Washington, who is now 22, said in an interview at his home in the Bronx that he wrote the mayor and provided a detailed account of the abuse, and asked to be transferred elsewhere. He said he never received a response.

Mr. Washington was transferred from Rikers Island to the Albany facility in March, two weeks after he said he got into an altercation with a city deputy warden. He was there until November and released from the New York State Department of Corrections and Community Supervision in Albany on Monday. He had been convicted of attempted robbery.