NEW YORK (AP) — New York City has sent dozens of young Rikers Island inmates to an upstate jail where they have been brutalized and held in solitary confinement, despite a city policy barring such confinement for anyone under 22, a federal lawsuit has alleged.

A complaint filed Friday accuses the city of using jail transfers to punish inmates it deems undesirable — many have been charged with assaulting Rikers guards — and to circumvent its solitary-confinement rules.

The Albany County jail staffers have unjustly beat the young men and forcibly conducted rectal searches, the civil rights suit says.

"It is time for the torture to stop," lawyers Katherine Rosenfeld, Douglas Lieb and Steven Goldman wrote in the suit.

It was filed on behalf of four current and former Rikers inmates sent to the Albany County jail while awaiting trial. Two were under 22 at the time; the others were older.

The New York Times, which first reported the suit, said city mayoral spokesman Eric Phillips said the jail transfers were for the inmates' own security.

"For an extremely small number of young detainees facing credible safety threats in our jails, the safest option is a transfer to another facility," he told the newspaper.

The Associated Press sent Phillips an email seeking comment Saturday. Messages were also left with the Albany County Sheriff's Office and a county official.

Under state law, county jails can transfer inmates for reasons that include threats to their own safety.

Young Rikers inmates have been taken to Albany without notice and greeted by what's dubbed the "Green Team," guards in paramilitary uniforms and riot gear with a leader who warns: "This isn't Rikers. ... We do what we want here," according to the suit.

The guards issue puzzling commands — "face the wall with your right foot behind your left and your right hand higher than your left," for instance — and punch and beat the inmates for flubbing, the suit says.

It alleges they are then body-scanned for concealed contraband and, regardless of whether anything is found, are often subjected to searches by guards who insert fingers and sometimes batons into the young men's rectums.

Then the inmates are almost always put into solitary confinement, the suit says.

It seeks unspecified damages and court declarations that the practices at issue are unconstitutional, among other requests.