Michael Avenatti, the former lawyer for Stormy Daniels, a porn star, pleaded guilty to five criminal charges in federal court on Thursday.

Avenatti pleaded guilty to four counts of wire fraud from defrauding clients as well as one tax-related charge during a court hearing in Santa Ana, California. He faces a maximum sentence of 83 years in prison.

The lawyer, who is representing himself, failed to reach a deal with federal prosecutors earlier in the week but decided to change his plea in an effort to hold himself accountable and avoid any further embarrassment to his family.

He admitted to obstructing and impeding efforts by the Internal Revenue Service to collect unpaid payroll taxes, which add up to $5 million.

MICHAEL AVENATTI TO PLEAD GUILTY IN REMAINING CRIMINAL CASES

Stormy Daniels and Michael Avenatti during a news conference

Adult film actress Stormy Daniels, left, stands with her lawyer Michael Avenatti during a news conference. (AP Photo/Mary Altaffer, File)

In addition to the five criminal charges Avenatti pleaded guilty to on Thursday, he could also face an additional 31 counts depending on if the government wants to pursue those. A decision on the remaining 31 counts is expected next week.

Avenatti's sentencing date will be in mid-September if the government opts not to pursue the remaining 31 counts.

He will be forced to pay fines in excess of $1 million and restitution which the government says is $14 million.

The hearing was delayed on Thursday morning while Avenatti met with his appointed counsel, then told the judge that he's "prepared to plead guilty to five counts this morning."

MICHAEL AVENATTI, STORMY DANIELS WERE HYPED BY MEDIA AS TRUMP'S DOWNFALL BEFORE LEGAL FALLOUT

Michael Avenatti speaking at press conference

Michael Avenatti, attorney for porn actress Stormy Daniels, talks to reporters outside federal court in Los Angeles, Tuesday, Jan. 22, 2019. A federal judge appeared inclined to toss out a lawsuit against President Donald Trump by Daniels that seeks to tear up a hush-money settlement about their alleged affair. Avenatti argued the case should continue because he wanted to take sworn statements from Trump and Cohen. He plans to ask for legal fees. (AP Photo/Brian Melley)

Avenatti is serving five years in a federal prison in California for two convictions handed down in New York in relation to stealing book proceeds from Daniels. 

He was also convicted of attempting to extort Nike if it didn't pay him up to $25 million.

In a previous filing on June 12, Avenatti’s lawyer said that a plea deal was unable to be reached with the government.

CLICK HERE TO GET THE FOX NEWS APP

"Despite repeated efforts over the last year by Mr. Avenatti and his counsel, including substantial efforts made in the last 30 days, defendant has been unable to reach a plea agreement with the government," Avenatti’s lawyer said. "Mr. Avenatti wishes to plea in order to be accountable; avoid his former clients being further burdened; save the Court and the government significant resources; and save his family further embarrassment." 

Avenatti has been suspended by the State Bar of California.

The Associated Press and Fox News' Ross Lee and Bradford Betz contributed to this report.