By Joe Holden, Greg Argos and Kristen Johanson

PHILADELPHIA (CBS/AP) — In a surprise development, the city’s top prosecutor pleaded guilty Thursday to a corruption charge, resigned from office and was sent immediately to jail by a judge who said he couldn’t be trusted.

Two weeks into his federal trial, District Attorney Seth Williams pleaded guilty to a single count of accepting a bribe from a businessman.

Counts 2 through 29 have been dismissed, but in the agreement, Williams must acknowledge misconduct.

“I’m very sorry,” Williams told the court, choking up as he acknowledged he would resign.

In a resignation letter obtained by CBS3, Williams penned this letter moments before he pleaded guilty.

U.S. District Judge Paul Diamond said he was not inclined to trust Williams’ assurances about appearing for sentencing set for Oct. 24, so ordered him immediately jailed. He was led out of the courtroom in handcuffs.

Day 7 Of Testimony In Seth Williams Trial Focuses On Campaign Finances

Diamond said he was appalled by the evidence he heard during the jury trial, and had concluded Williams “sold” his office.

Williams faces up to five years in prison.

The move came after weeks of damaging testimony against Williams, a two-term Democrat who didn’t run for re-election this year.

The 50-year-old Williams was accused of illegally accepting gifts from two businessmen in exchange for legal favors. He was also charged with fraudulently using thousands of dollars from his campaign fund for personal expenses, misusing city vehicles and misappropriating money intended to fund his mother’s nursing home care.

Williams, a graduate of Georgetown Law School, was the city’s first black district attorney.

Although he had remained in office after being indicted, his law license was suspended and a deputy was put in charge.

Last year, before he was indicted, he belatedly filed financial disclosure reports showing he had accepted about $175,000 in cash, gift and trips from friends as he struggled to maintain his family’s lifestyle after a divorce. He was fined $62,000 by the city ethics board, its largest fine ever.

The Philadelphia District Attorney’s Office addressed Williams’ resignation in a statement:

“The Philadelphia District Attorney’s Office embodies the phrase that the whole is greater than the sum of its parts,” said Kathleen Martin, First Assistant for the Philadelphia District Attorney’s Office via a statement. “The Assistant District Attorneys and professional staff of the Philadelphia District Attorney’s Office are among the finest in the country. Throughout this unfortunate period they continued to display the diligence, fortitude, and integrity that has historically been a hallmark of the Office. I could not be more proud of how my hardworking colleagues have conducted themselves in light of the investigation and prosecution of Mr. Williams, and now with the conclusion of this case, Philadelphians should know that their District Attorney’s Office continues the pursuit of justice and the hope for a safer city endures.”

“It was time for District Attorney Seth Williams to do right by Philadelphia and resign,” said Chancellor Deborah R. Gross in a statement Thursday. “The hard work of those professionals in the Office of the District Attorney should not be tainted by the actions of one individual.

The judge has set a sentencing date of October 24.

CAN THE OFFICE RETURN TO NORMAL?

With Williams in jail — and facing prison — questions about what it all means for the cases he handled and the future of the Philadelphia District Attorney’s Office remains unclear.

“He did the right thing. He should have done it earlier. It’s time to move on and we will have a new DA in January and life will go on,” said Mayor Jim Kenney.

But in the meantime, work within the Philadelphia District Attorney’s Office must go on under the guidance of first assistant DA Kathleen Martin.

“The Philadelphia District Attorney embodies the phrase that the whole is greater than the sum of its parts,” said Martin. “I think we are all cognizant of the fact we need to move on and that’s just the next step and we will continue and want to do that,” said Martin.

She praised her staff during the most difficult of times.

“Throughout this unfortunate period, they continued to display the diligence, fortitude and integrity that has historically been the hallmark of this office.”

And she promised Philadelphians the very people who elected the former DA– now in federal custody–the respect and high ethical standard of the city and county’s top law enforcement office.

“If you look around to all these people, they are dedicated public servants. And they want to do their job and they want to do it well. So the morale is that it’s deep inside of them,” said Martin. “Philadelphians should know that DA’s office continues the pursuit of justice, and the hope for a safer city.”

Former Philadelphia District Attorney Lynne Abraham worked with Williams for 10 years.

She says she was surprised that he was led away in handcuffs after the guilty plea, and immediately taken into custody.

“The fact that Judge Diamond made a credibility judgement that he didn’t believe a thing Mr. Williams said and committed him to prison,” said Abraham. “Going from chief law enforcement officer to prisoner is a pretty steep and a pretty high fall. It’s not the way that that should have turned out. Here’s a man that could have been the mayor, maybe even the governor. Who knows where his future could have led him.”