HOUSTON (AP) A federal judge accused of groping two of his former female court employees and trying to force them to perform sex acts pleaded guilty on Monday to obstruction of justice in exchange for prosecutors dismissing sex crimes charges against him.

U.S. District Judge Samuel Kent also retired Monday, effective immediately, thereby avoiding possible impeachment by Congress.

Kent's guilty plea came as jury selection in his trial was set to begin.

The jurist, who once shouted in court that he would bring "hordes of witnesses" in his defense, spoke barely above a whisper as he pleaded guilty to lying to a judicial committee investigating the sex-related charges. He and his lawyer, Dick DeGeurin, told the presiding judge that he was taking medication for depression and anxiety as well as diabetes and was under the care of both a psychiatrist and a psychologist.

"Judge Kent believes this compromise settlement was in the best interests of all involved," DeGuerin said in a statement after the hearing. "A trial would have been embarrassing and difficult for all involved."

Kent, 59, had been facing six charges five related to federal sex crimes and the obstruction charge, a felony that alone carries a maximum sentence of up to 20 years in prison and a fine of up to $250,000.

Kent was the first federal judge charged with a sex crime and would have been one of only a handful to be tried.

If he had been convicted of the most serious federal sex crimes charges against him, Kent could have received a sentence of up to life in prison.

Kent, appointed by President George H.W. Bush, has been on the bench for nearly 19 years. Federal judges are appointed for life and can only be forcibly removed through impeachment by Congress.

Kent had vigorously maintained his innocence. DeGuerin had said the judge's conduct with the two women was mutual and consensual.

Prosecutors had said they would present evidence showing there was nothing consensual about what Kent did with the two women, Cathy McBroom, his former case manager, and the judge's former secretary.

The Associated Press does not normally name alleged victims of sexual abuse, but McBroom's attorney and her family have used her name in publicly discussing the case.

Both women were in the courtroom as Kent entered his guilty plea.

Authorities first investigated Kent after McBroom filed a complaint against him in May 2007 and the Judicial Council of the 5th U.S. Circuit Court of Appeals began a probe.

McBroom accused Kent of harassing her over a four-year period, culminating in March 2007, when she said the judge pulled up her blouse and bra and tried to escalate contact until they were interrupted.

The judicial council suspended Kent in September 2007 for four months with pay but didn't detail the allegations against him. It also transferred him to Houston, 50 miles northwest of Galveston, where he had worked since being appointed in 1990.

A Justice Department investigation of McBroom's claims led to Kent's indictment in August on three federal sex charges.

Last month, prosecutors added two more sex charges and the obstruction charge, accusing Kent of trying to engage his former secretary in a sex act and then lying about it to the judicial council.

DeGuerin had said Kent and his secretary were involved in a longtime affair and he didn't reveal it to the judicial council because he was being a "gentleman."

Copyright 2009 The Associated Press.