By the start of the Fourth of July weekend, pretrial negotiations between District officials and lawyers representing the city's 300 young offenders had stretched nearly around the clock for days, and still unsettled was the appointment of a monitor for the city's juvenile facilities.

City officials had already rejected one candidate when the lawyers, who had filed a class-action suit in D.C. Superior Court charging unsafe conditions at the city's juvenile facilities, brought up the name of Michael Lewis, a D.C. native and an old hand at mediation.

"Their first proposal seemed like a slap in the face," said city attorney Roberta Gross after the announcement Thursday of the precedent-setting agreement. "Their next real legitimate proposal was Mr. Lewis . . . . We checked around, and everybody said Lewis is a neutral fact-finder who will not get middled by either party."

"I expect it to be a tough monitorship," said Lewis, 43, who will supervise the sweeping reforms of the facilities agreed to by the city, as well as consult on ways to accomplish them. "Not because of any ill will on anyone's part. But just reading the agreement you can see there's lots to be done. Institutions are difficult things to change in the best of circumstances."

Lewis is no stranger to institutional problems. Currently deputy director of the International Institute for Dispute Resolution, Lewis has spent a substantial portion of the past 15 years crisscrossing the country to help other jurisdictions resolve crises in their correctional systems.

He was appointed a special master at a state penitentiary in Washington and has served as a consultant to some of the most volatile institutions in the country, including facilities in Ohio, Georgia, Texas and New York. For several years he assisted the California Youth Authority in creating a grievance system through which youthful offenders could complain about their treatment.

Lewis' job here will be to ensure compliance with the agreement, which calls for closing Cedar Knoll, the most dilapidated of the three facilities; nearly doubling professional staffing at the other two, and improving educational, medical and therapeutic services. Also, the city said it will curb disciplinary actions against residents and abide by national housing and health standards. The D.C. government will compensate Lewis, who will submit a budget to the court for approval.

By agreeing to the settlement of the suit, the city avoided a potentially lengthy and embarrassing trial of practices by the city's Youth Services Administration, which is a subject of a wide-ranging criminal investigation by federal authorities.

Lewis was chosen to serve as the eyes and ears of the court after each party to the suit had balked at the other's initial candidate.

City officials turned down as partisan the proposed appointment of a former chief attorney for the American Civil Liberties Union's National Prison Project, which joined the city's independent public defenders in suing the city.

Lawyers for the juveniles rejected the city's suggestion that former Superior Court judge John D. Fauntleroy, the mayor's special assistant overseeing conditions at Lorton Reformatory and the D.C. Jail, assume the monitoring of the juvenile facilities as well. As a compromise, the two sides agreed that Lewis should consult Fauntleroy to give the city a greater voice.

"We knew we would have a problem coming up with finding people who were acceptable to both sides, so we had a roster of people," said Stephen Ney, an attorney with the National Prison Project. "We next suggested Mike because of his mediating background and his skill and personality. He is a known quantity to some people in the District. He fit the bill."

It was Lewis' career in mediation, besides his experience in correctional management, that made him an attractive candidate to city officials. Although Lewis will issue reports to Superior Court Judge Ricardo M. Urbina, city negotiators regard Lewis as someone willing to try to work out problems before resorting to court interference.

"Traditional advocacy of prisoners' claims has to happen," said Lewis. "But there are also a lot of problems that occur in any institution, particularly a closed institution, for which other kinds of mechanisms for resolving grievances make sense."