President Trump’s former lawyer Michael Cohen tweeted a self-congratulatory post about his cooperation with special counsel Robert Mueller that was actually written by his own lawyer.

“Good for @michaelcohen212 in providing critical information to the #muellerinvestigation without a cooperation agreement. No one should question his honesty, veracity or loyalty to his #family and #country over @potus @realdonaldtrump,” the late Thursday tweet read.

But then Cohen deleted it — and his lawyer Lanny Davis posted it on his account, saying he wrote the post and sent it to Cohen to tweet because Cohen has more followers.

“FYI – I wrote a Tweet congratulating @MichaelCohen212 and sent text to him to Tweet to his much larger following – but was delayed posting myself so he posted first. All take a breath. I don’t control or have access to Mr. Cohen’s Twitter account. He is my client and my friend,” Davis wrote.

“my Tweet sent to @MichaelCohen212 and I asked him to re-send to his followers-Good for @michaelcohen212 in providing critical information to the #muellerinvestigation without a cooperation agreement. Don’t question his honesty, veracity or loyalty to his #family, #country,” he added in a third tweet.

The confusion followed the disclosure by ABC News that Cohen has had multiple sitdowns with Mueller’s team in recent weeks.

Investigators are grilling Cohen — once one of Trump’s closest confidants — about the president’s dealings with Russia, including business deals, financing as well as his campaign’s possible collusion with the Kremlin.

Investigators also want to know whether the president ever dangled a possible pardon for Cohen in an effort to zip his lips, the network reported, citing sources.

Trump has variously slammed Mueller’s probe as a “witch hunt“ and “a hoax” cooked up by Democrats as an excuse for losing the 2016 election.

Cohen has voluntarily cooperated with Mueller’s team after pleading guilty to eight criminal counts last month.

Rudy Giuliani, Trump’s personal lawyer, called Cohen “an honest, honorable lawyer” in May — but more recently said “he’ll lie like crazy” to get leniency at his sentencing.