The plea deal brings to an end a seven-months-long ordeal that led to felony charges against Kilpatrick and plunged the city, region and state into political chaos.
"I lied under oath," Kilpatrick said in court.
As part of the deal, the 38-year-old Democrat is to serve four months in jail and five years of probation. He also would pay the $1 million in restitution over the five-year probationary period.
During a separate hearing moments after Wayne County Circuit Court Judge David Groner accepted the mayor's plea, Kilpatrick offered a no contest plea in an assault case.
The judge also accepted that plea, which called for Kilpatrick to serve a four-month jail sentence that would run at the same time.
Kilpatrick had faced 10 felony counts in the two separate criminal cases.
Groner asked Kilpatrick if he understood he was giving up the right to be innocent until proven guilty.
"I gave that up a long time ago," Kilpatrick replied.
The soon-to-be former mayor added, "I lied under oath in the case of Gary Brown and Harold Nelthrope versus the City of Detroit... regarding information that was related to claims made by Gary Brown and Harold Nelthrope," he said.
"I did so with the intent to mislead the court and the jury and to impede and obstruct the fair administration of justice," reports CBS station WWJ.
The married mayor and former top aide Christine Beatty were charged in March with perjury, misconduct and obstruction of justice. They're accused of lying under oath about an affair and their roles in the firing of a deputy police chief.
Beatty did not plead guilty and next will appear in court on Sept. 11. Groner said a plea deal in Beatty's case appeared likely.
The mayor will be sentenced on Oct. 28. He will report to jail that day, said Wayne County Prosecutor Kym Worthy.
"We did not give an inch and these conditions were basically to a letter of what we wanted all along," she said.
The mayor has to announce his resignation immediately, and it will become effective within two weeks.
Worthy said she was glad that Kilpatrick resigned but that was never a "bargaining chip" for her. She said paying restitution and serving time in jail were far more important.
"You don't just lose your job and walk away," she said.
City Council President Ken Cockrel Jr. will succeed Kilpatrick as mayor until a special election is held.
Until now, Kilpatrick had refused to resign even as the calls for him to step down grew louder and the controversy overshadowed all else at City Hall, tarnishing the national image of the much-maligned city even more.
Kilpatrick leaves a mixed legacy. He persuaded big business to invest in a city staggering from the auto industry's woes and a decades-long exodus of people, but he failed to live up to a promising political future due to repeated scandal.
The son of a Detroit congresswoman, Kilpatrick was just 31 when he was elected in 2001, becoming the youngest mayor in city history.
His pro-Detroit rhetoric and diamond stud earring endeared Kilpatrick to many blacks, especially young voters who embraced the "Hip-Hop Mayor."
But Kilpatrick's first term was marked by political immaturity and fiscal irresponsibility. He racked up thousands of dollars in travel on his city-issued credit card and the city's lease of a luxury Lincoln Navigator for his wife, Carlita.
Less than a year into the first term, rumors surfaced of a wild party involving strippers and members of Kilpatrick's security team at the mayor's mansion.
Former Deputy Police Chief Gary Brown filed a lawsuit in 2003, claiming he was fired for looking into the alleged party and investigating the actions of the mayor's bodyguards.
During the 2007 trial, Kilpatrick and Beatty sat in the witness chair and denied having a romantic relationship in 2002 and 2003.
But a bombshell rocked Detroit in January: The Detroit Free Press published sexually explicit text messages recovered from Beatty's city-issued pager that contradicted their courtroom denials.
He and Beatty were charged with perjury and other felonies.
More text messages released in April revealed the evolution of flirty and sexually explicit exchanges to professions of love and promises of marriage.
In May, the City Council asked Granholm to remove Kilpatrick from office, saying it was misled into approving a $8.4 million settlement with Brown and two other officers. Council members said they didn't know about provisions to keep the text messages under wraps.
In July, a sheriff's detective trying to serve a subpoena on a Kilpatrick friend said he was shoved by the mayor. Assault charges followed.
The next month, a judge ordered the mayor to jail for violating the terms of his bond by traveling to Canada. He was released the next day, but the incident prompted some politicians and community leaders who had remained silent on the scandal to call for his resignation.