Time for Trump to panic.

Michael Cohen, who had been Trump’s longtime “fixer” and personal attorney, pleaded guilty to a total of eight charges Tuesday — and he implicated Trump in the process.

He pleaded guilty to tax evasion, making false statements to a financial institution, unlawful corporate contributions, and excessive campaign contributions.

Cohen said he violated campaign law at the direction of an unnamed candidate for federal office for the purpose of influencing the election.

In other words, he did it for Trump because Trump told him to.

The story first broke in January that Trump’s attorney had paid $130,000 in hush money to porn star Stormy Daniels, just weeks before the 2016 election, to keep her silent about her affair with Trump. Trump’s new attorney, Rudy Giuliani, has since admitted Trump knew about the payment.

That payment raised questions about a possible campaign finance violation: If the payment was made to benefit Trump’s campaign, and was not disclosed as such, it could be illegal. And indeed, one of the charges Cohen pleaded guilty to came as a result of facilitating this payment.

The FBI raided Cohen’s office and hotel room in April, seizing “records related to several topics including payments” to porn star and alleged Trump mistress Stormy Daniels.

Additional stories have since emerged about other payments Cohen made on Trump’s behalf, prior to the 2016 campaign.

In July, a tape leaked of Cohen and Trump discussing a payment to shut down the story of Playboy model Karen McDougal’s affair with Trump.

McDougal signed a $150,000 exclusive contract to tell her story to the National Enquirer. David Pecker, the chairman of the Enquirer’s parent company, is a longtime friend of Trump’s. The Enquirer never ran that story.

Cohen admitted to paying her hush money as well.

Cohen has long been known as Trump’s “pit bull” for his hyper-aggressive, and often shady, representation of Trump.

In 2015, when the Daily Beast reported that Trump’s first wife, Ivana, claimed he had raped her when they were married, Cohen defended Trump by wrongly insisting that you cannot rape your spouse.

Cohen also threatened the journalist who was reporting on the allegations.

“I’m warning you, tread very fucking lightly, because what I’m going to do to you is going to be fucking disgusting,” Cohen said. “You write a story that has Mr. Trump’s name in it, with the word ‘rape,’ and I’m going to mess your life up … for as long as you’re on this frickin’ planet.”

Cohen’s fierce loyalty to Trump was legendary. He had once said he would be willing to take a bullet for his client.

But that has changed in recent months. In June, a friend of Cohen’s suggested to CNN that he might be willing to flip on Trump.

“He knows a lot of things about the President and he’s not averse to talking in the right situation,” the friend said. “If they want information on Trump, he’s willing to give it.”

Another friend said Cohen was feeling “let down” and “isolated” by Trump.

Cohen’s own attorney, Lanny Davis, said Cohen was no longer willing to take a bullet for Trump. He has been released on $500,000 bail and will return to court for sentencing on Dec. 12.

What Cohen has thus far shared with investigators about his longtime client is not yet known. That he has admitted to breaking the law for Trump, in order to win a presidential election, is bad enough.