DETROIT — Embattled mayor Kwame Kilpatrick, whose text-messaging scandal involved months of legal wrangling by a massive team of heavy-hitter lawyers, is going to jail, losing his job and law license, and has to cough up a $1 million fine for lying under oath.

Kilpatrick, the 38-year-old leader of the nation’s 11th largest city, pleaded guilty Thursday to two felony charges stemming from his false testimony at a whistleblower trial that cost the city $8.4 million. Kilpatrick denied having an affair with his chief of staff and firing a police officer, testimony that was contradicted by text messages published by the Detroit Free Press in January.

“I lied under oath,” Kilpatrick said in court this morning, an admission that forced his resignation.

Kilpatrick, who was charged with perjury, obstruction of justice and misconduct, will serve four months in jail and surrender his law license.

He will be on probation for five years, and is prohibited from running for office for that same time period.

Kilpatrick’s defense team of more than 17 public and private attorneys included Chicago powerhouse attorney Daniel K. Webb, chairman at Winston & Strawn who served as lead counsel in the recent public corruption trial of former Illinois Gov. George H. Ryan, Also helping Kilpatrick was Alabama attorney Jim Parkman, of Birmingham, Ala.’s Parkman, Adams & White, best known for successfully defending former HealthSouth CEO Richard Scrushy, who was acquitted of 36 various fraud charges in 2005.

Kilpatrick also had public relations help from federal prosecutor Judy A. Smith, who now runs a media strategy team from Washington D.C.

Kilpatrick faced a total of 10 felony charges ­ two of them stemming from a separate assault incident in which he was accused of shoving a detective who was trying to serve a subpoena to one of the mayor’s friends. Kilpatrick pleaded no contest to that charge today.

For Wayne County Prosecutor Kim Worthy, Kilpatrick resigning wasn’t enough.

He needed to pay for his actions, she stressed, with jail time and restitution.

“You don’t just lose your job and walk away,” Worthy said.

Kilpatrick will be sentenced Oct. 28.