The Montgomery County state's attorney's office will pay a former prosecutor $320,000 to settle her sexual discrimination lawsuit against former state's attorney Robert L. Dean, who she said fired her because she ended their two-year affair.

Under the terms of the civil settlement reached yesterday between Teresa Whalen and current State's Attorney Douglas Gansler (D), neither Dean nor anyone else admitted any wrongdoing in Whalen's firing in May 1997. The settlement also covers the county and I. Matthew Campbell, Dean's former deputy, whom Whalen also sued.

The agreement ended the federal suit that has loomed over Montgomery County for two years as both political fodder and courthouse gossip. Many local political observers attributed Gansler's defeat of Dean in last year's Democratic primary in part to Whalen's lawsuit.

Whalen said she felt vindicated by the settlement and called it a "clear message that I was wronged and my suit had merit." Dean, meanwhile, issued a one-page typed statement calling it a "bizarre" and "unprecedented giveaway arrangement" that he did not agree to.

Dean, who is now a prosecutor in Prince George's County, said he was not involved in the negotiations and that he wanted the case to go to trial so he could defend what he called a proper firing.

"Ms. Whalen filed suit and she alleged some pretty nasty things about me," Dean wrote. "Let the justice system take its course."

Gansler said he took it upon himself to settle the case directly with Whalen, even though the lawsuit was filed before he was elected in November, because litigating it might have been even more costly.

"You had Bob Dean admitting a long-term affair [in the media], you have him as her boss and you have him firing her," Gansler said. "I'm not saying that would have carried the day, but there was certainly some great financial exposure to the county if it did go to trial."

One week before the Democratic primary election, Whalen's lawyer, Chris Mackaronis, released to the media two romantic poems that he said Dean had written to Whalen. Mackaronis also said Dean had tried to stall the lawsuit's progress until after the election.

Gansler said his employees, many of whom likely would have been deposed or subpoenaed to testify, expressed relief about an end to a case that tore at longtime professional and personal ties.

"This would have been a knockdown, drag-out fight in our office over two people who don't work there," Gansler said. "Nobody in the office wants to relive that situation."

He said the $320,000 would be paid to Whalen and her lawyer from the $7 million allocation to the state's attorney's office in the county budget. The County Council, which must approve any expenditure of more than $5,000, approved it, he said.

Both Dean and Whalen were veteran prosecutors -- Whalen was the office's top female prosecutor until her firing -- and they tried some of Montgomery's most high-profile criminal cases. In 1995 and 1996, they teamed up in the highly publicized trials of a Detroit hit man and the California man who had hired him to kill his ex-wife, disabled son and the boy's nurse in Silver Spring.

It was during that time, Whalen said, that they conducted their affair. After she broke it off in the fall of 1996, Dean continued to make sexual advances, according to her lawsuit. When she refused them, Dean retaliated by not promoting her, reassigning some of her felony cases to less experienced prosecutors and excluding her from decision-making discussions, Whalen alleged.

She further alleged that Dean and Campbell tried to damage her reputation by saying publicly that she had been fired for failing to cooperate in a police investigation into a former boyfriend. Whalen also initially sued Charles W. Thompson Jr., the county attorney, on allegations that he did not protect her from the alleged sexual discrimination, but he was later dropped from the suit.

Campbell, who is now a deputy state's attorney in Howard County, said he, too, had no part in negotiating the settlement.

"When you've been wrongly accused in a mean-spirited way, there's a degree of relief in having it over," Campbell said, "but I would have been just as happy to see it dismissed by a judge."

Dean and Whalen's relationship first surfaced publicly in early 1997, when Whalen's former boyfriend, Montgomery police Sgt. Michael Mancuso, left a recording on the state's attorney's office voice-mail system of a phone conversation in which Whalen described her relationship with Dean.

In his statement yesterday, Dean again said he fired Whalen "in light of her efforts to obstruct a police investigation" into possible illegal wiretapping by Mancuso in the voice-mail incident -- allegations she has denied. Mancuso was later cleared of any wrongdoing.