Michael Avenatti -- the lawyer who became famous representing porn star Stormy Daniels, later served as counsel for a woman whose claims of a gang rape ring run by a Supreme Court nominee were quickly cast into doubt and who is now mentioned as a possible 2020 Democratic presidential candidate -- was ordered to pay nearly $5 million to an attorney at his former firm, a California judge ruled Monday.

The judge at the hearing in Los Angeles County Superior Court – which Avenatti did not attend -- said Avenatti must pay $4.85 million because he personally guaranteed a settlement with attorney Jason Frank in a lawsuit over back pay.

Frank had alleged the firm misstated its profits and he was owed millions.

Los Angeles Superior Court Judge Dennis Landin issued the ruling after turning down a request from Avenatti to have the matter moved to federal court, which the opposing side called a delay tactic.

Monday's decision also follows an earlier ruling from a U.S. bankruptcy court judge who ordered Avenatti's former firm to pay $10 million to Frank.

Avenatti, meanwhile, told The Associated Press that Frank owes him and the firm $12 million "for his fraud" – but didn't provide details of what that fraud was.

The latest legal setback for Avenatti comes a day after The Daily Beast published a report highlighting how he allegedly lived extravagantly -- while owing millions of dollars in unpaid taxes.

The lawyer – who's become something of a celebrity critic of President Trump – was criticized by the commander-in-chief last week after a federal judge tossed out a defamation lawsuit brought by Avenatti.

“I just beat him in a big case. … Beat him badly. In fact, he has to pay me legal fees,” Trump told Fox Business’ Trish Regan. “I don’t think he has any money, but he and [Stormy Daniels] have to pay me a lot of legal fees.”

Trump has denied the affair allegations but acknowledges a hush-money payment was made.

Fox News' Frank Miles and the Associated Press contributed to this report.