DETROIT, Michigan (CNN)  -- A defiant Mayor Kwame Kilpatrick addressed Detroit on Thursday night listing what he said the city had accomplished under his leadership just hours after announcing his resignation amid a sex and perjury scandal.



Detroit Mayor Kwame Kilpatrick has agreed to resign from office, a prosecutor said Thursday.



"The city is much better shape than the city I received seven years ago," said Kilpatrick. "We in Detroit have done amazing things together."



During the speech Kilpatrick also jabbed city officials and Michigan's governor, telling them to continue to work for the people of Detroit as hard as they did to get him out of office.



Kilpatrick told the crowd his marriage is better than it has ever been and kissed his wife to end the speech, an act that brought thunderous applause. Kilpatrick said he decided to step down so the city could continue to move forward.



"Sometimes standing strong means stepping down," Kilpatrick said. "But Detroit you have set me up for a comeback."



The embattled Kilpatrick pleaded guilty Thursday to charges resulting from a sex scandal and submitted his resignation to the governor -- effective in two weeks.



Under a plea deal, Kilpatrick will serve four months in the Wayne County Jail and the rest of his five-year sentence on probation, said Wayne County Prosecutor Kym Worthy.



He will enter jail on the day of his formal sentencing, October 28, she said.



Kilpatrick, 38, also agreed not to run for public office during his probation, to pay $1 million in restitution and to forfeit any future pension.



He was accused of blocking a criminal investigation into his office and firing a police deputy to cover up an extramarital affair and other possible illicit activities.



After the deputy, Gary Brown, lost his job, a mayoral bodyguard, Officer Harold Nelthrope, left his job voluntarily when the atmosphere became too tense, said his attorney in the whistle-blower suit trial.



Walt Harris, another former mayoral bodyguard, filed his own whistle-blower suit, contending he was punished for supporting Nelthrope's reports of wrongdoing by Kilpatrick and his bodyguards.



The city of Detroit paid $8.4 million to settle the lawsuits, but legal fees have pushed that figure to at least $9 million.



Prompted by the judge to recount his wrongdoing, Kilpatrick admitted Thursday, "I lied under oath in the case of Gary Brown and Harold Nelthrope versus the city of Detroit. ... I did so with the intent to mislead the court and the jury and to impede and obstruct the fair administration of justice."  Watch Kilpatrick in court »



When Circuit Court Judge David Groner asked Kilpatrick if he understood that by pleading guilty he was giving up the right to be presumed innocent until proven guilty, the mayor said, "I think I gave that up a long time ago, your honor. Yes."



Kilpatrick had faced eight felony counts. As part of the agreement, six counts related to misconduct in office were dropped, and a perjury count was changed to a second obstruction of justice charge.



In a separate case against Kilpatrick, Groner on Thursday accepted a no-contest plea on an assault charge brought against the mayor in July after he allegedly shoved a police officer trying to serve a subpoena on a friend of Kilpatrick's who was a potential witness in his perjury case.



Groner set an October 28 sentencing date for both cases.



Also Thursday, Michigan Gov. Jennifer Granholm adjourned a hearing on whether to remove Kilpatrick from office after he notified her of his pending resignation.



"Today, this sad but historic story is coming to an end," Granholm said.



"It's very important for us as a state and as a city to turn this page together. There is much work to do. It is my profound hope that we can now write a new history for this great but embattled city."  Watch Granholm call for a new chapter »



The governor set the hearing after the Detroit City Council voted in May to ask her to remove Kilpatrick, alleging he had misled the council by
What charges does Kilpatrick plead guilty to? What has Kilpatrick told officials? What did he plead guilty too what did kilpatrick do who is kilpatrick Who was charged who goes to jail What has Kilpatrick agreed not to do? What were the charges
sex scandal telling them to continue to work for the people of Detroit as hard as they did to get him out of office. charges resulting from a sex scandal agreed to resign from office, Detroit Mayor Kwame Mayor Kwame Kilpatrick Kilpatrick run for public office during his probation, resulting from a sex scandal
question: What charges does Kilpatrick plead guilty to?, answer: sex scandal | question: What has Kilpatrick told officials?, answer: telling them to continue to work for the people of Detroit as hard as they did to get him out of office. | question: What did he plead guilty too, answer: charges resulting from a sex scandal | question: what did kilpatrick do, answer: agreed to resign from office, | question: who is kilpatrick, answer: Detroit Mayor Kwame | question: Who was charged, answer: Mayor Kwame Kilpatrick | question: who goes to jail, answer: Kilpatrick | question: What has Kilpatrick agreed not to do?, answer: run for public office during his probation, | question: What were the charges, answer: resulting from a sex scandal