In the court filing, Mr. Bharara’s office said it was also writing on behalf of the Legal Aid Society and the law firms Emery Celli Brinckerhoff & Abady and Ropes & Gray, as well as for the city. The parties expect to be able to submit the agreement for approval by the court no later than July 1, the filing said.

Although the agreement was embraced wholeheartedly by Mr. de Blasio; Joseph Ponte, the city’s correction commissioner; and Zachary W. Carter, the city’s corporation counsel, the negotiations dragged out in recent weeks, to the point that Mr. Bharara publicly expressed frustration at their pace. He declared at a news conference this month that “every day that goes by where we don’t have enforceable and enduring reform at Rikers Island is one day too many.”

In one dispute, The Times reported, the city objected to a provision that would require the Department of Correction to notify the United States attorney’s office whenever it referred a potentially criminal use of force episode to the city’s Investigation Department. The filing on Monday indicates that the provision remains in the final deal.

In focusing on the treatment of young inmates, the agreement ends the use of punitive segregation for inmates under 18 as well as for 18-year-olds with serious mental illness, the filing says. Mr. Ponte has already imposed a series of reforms at Rikers, including, for example, ending solitary confinement for 16- and 17-year olds.

The filing says that the lawyers for the individual named plaintiffs in the Nunez class action had reached an agreement in principle with the city to resolve most of their individual damages cases, which are still subject to approval by their clients. The 11 plaintiffs, all men, said they had been beaten by correction officers at Rikers and two other city correction facilities, the lawsuit shows. A 12th plaintiff settled his case in December for $200,000, according to the Law Department.

Despite the current and pending reforms, the city is still struggling to get violence at Rikers under control. As recently as Monday, three inmates were slashed in gang-related attacks, prompting the department to take the unusual step of locking down the city’s entire correction system, including the 10 jails on Rikers Island and three borough jails, two officials with knowledge of the situation said on the condition of anonymity because they did not have permission to speak to the news media. The lockdown was still in effect on Monday evening.

One of the slashings occurred aboard a bus that was transporting inmates, the officials said. The extent of the inmates’ injuries was not immediately known.