A federal judge gave final approval yesterday to an $8.5 million settlement in a class-action lawsuit involving allegations of rampant sexual harassment of female employees at the D.C. Department of Corrections.

U.S. District Judge Royce C. Lamberth's ruling calls for the District to pay $6.5 million to 138 current and former employees who alleged they faced sexual harassment on the job and retaliation for complaining about it. Another $2 million will pay for attorney fees accrued in 5 1/2 years of litigation.

The decision establishes the mechanics of a settlement pact worked out nearly two years ago by lawyers for the District and the employees. The agreement called for Bessye Neal and seven other named plaintiffs to divide a total $1.6 million. Other money went into a pool for other damage claims.

A court-appointed special master, Alan Balaran, had wide discretion in sorting out claims and ordering improvements at the Corrections Department. Balaran ultimately recommended awards to 130 claimants, ranging from $2,000 to $200,000 apiece. The largest award is set to go to an unidentified woman who was raped, sexually accosted and repeatedly subjected to hostile comments. In addition, Balaran called for the promotion of nine employees and the rehiring of seven others who faced retaliation.

District officials have agreed to create a special inspector's office within the Corrections Department to investigate reports of sexual harassment and retaliation. The office will have authority to discipline employees, initiate training programs and set new policies and procedures.

The lawsuit, Neal v. the D.C. Department of Corrections, was filed in January 1994 by seven women and one man who are current or former corrections employees. They contended sexual harassment had been pervasive for years despite repeated complaints. Instead of rooting out the employees who acted improperly, the lawsuit alleged, those who spoke out faced punitive transfers or other retaliation.

After a jury ruled against the District in 1995, the case was sent back to Lamberth on appeal. The settlement negotiations then led to an agreement.

In yesterday's decision, Lamberth described a workplace "as sexually hostile as one can imagine," pointing to instances between 1989 and 1997 of "coerced sexual relationships ending in unintended pregnancies, sexual assault, unwanted grabbing, rubbing, and other sexual touching, and what seems a constant stream of sexually suggestive and sometimes abusive comments."

The judge reviewed specifics of the agreement during a heavily attended hearing in February. Not everyone who sought money will get it. The special master denied more than 100 claims because they either could not be fully documented or they covered conduct outside the time frame of the lawsuit.

The settlement agreement called for the District to set aside $8 million, and money was put into an escrow account in 1997. Since then, it has generated more than $500,000 in interest, bringing the total payout to $8.5 million.

"The role of this Court and this litigation is now largely completed," Lamberth wrote in his 78-page opinion. "However the process of genuine reform has only just begun."