WASHINGTON — When President Donald Trump fired James Comey in May, he said he was acting on the recommendation of Justice Department leaders who had faulted the FBI director for releasing “derogatory information” about Hillary Clinton at the conclusion of the email server investigation months earlier.

Yet with each tweet about the Clinton probe, Trump seems to be further undermining his administration’s stated rationale for a termination that’s now central to special counsel Robert Mueller’s Russia investigation.

The disconnect between Trump’s attacks on Comey’s handling of the email investigation and the criticism of Comey by his own Justice Department could muddy the explanation for exactly why Comey was fired, and may complicate efforts by the president’s legal team to present a coherent narrative as Mueller and his prosecutors examine whether the dismissal could support obstruction of justice allegations.

Trump has complained for months about the FBI’s decision not to pursue criminal charges against Clinton, his Democratic opponent in the 2016 presidential election, for her use of a personal email server. He has suggested the criminal investigation was rigged in her favor, claiming in one October tweet that Comey “totally protected” her. He recently seized on the revelation of politically charged text messages from an FBI agent who worked on that probe to again deride the investigation. And in a Saturday tweet that appeared to suggest Clinton should have been prosecuted, Trump caustically referred to “33,000 illegally deleted emails.”

Yet those attacks are increasingly hard to square with a Justice Department memo that the White House held up as justification for firing Comey. That document, authored by Deputy Attorney General Rod Rosenstein, cited an unusual July 2016 news conference in which Comey described Clinton and her aides as “extremely careless” as well as Comey’s notification to Congress, days before the election, that the investigation was being revisited because of the sudden discovery of additional emails.

AP check: Here’s how Donald Trump’s tweet about James Comey compares to facts

“From the beginning there’s always been serious doubt that the memo from the deputy attorney general was the actual reason the president fired the FBI director,” said Scott Fredericksen, a Washington criminal defense lawyer and former federal prosecutor. “These tweets,” he added, “probably don’t help the president in that regard.”

A lawyer for Trump did not return a phone message seeking comment.

Mueller’s team has been interested for months in the circumstances of Comey’s firing, with prosecutors obtaining an initial White House memo, drafted but never released, that purported to lay out a basis for Comey’s removal.

The final memo the White House released on May 9, signed by Rosenstein, castigated Comey for announcing that criminal charges were not warranted against Clinton even though such determinations are generally left to Justice Department prosecutors. He also faulted Comey for comments made during that news conference, which Rosenstein said broke with Justice Department protocol by issuing “derogatory information” about someone who was investigated but never charged. Though he did not explicitly say it, his assessment seemed in line with that of Clinton and her supporters — that Comey’s statements and actions during the investigation had harmed her election prospects.

“The Director laid out his version of the facts for the news media as if it were a closing argument, but without a trial,” Rosenstein wrote. “It is a textbook example of what federal prosecutors and agents are taught not to do.”

“Once you start picking on one tweet or one message, then it becomes, ‘What about this tweet or that message?’ You’re constantly having competing messages,” a Washington defense lawyer said.

In a single-page letter to Comey released alongside Rosenstein’s memo, Trump said he had accepted the Justice Department’s recommendation for termination.

From the start, though, that explanation has been tough to reconcile with Trump’s blistering attacks on Clinton, and his repeated assertions on the campaign trail and as president that she should have been prosecuted.

He returned to that theme days after Mueller revealed a plea deal with Michael Flynn, Trump’s former national security adviser, by tweeting: “Many people in our Country are asking what the ‘Justice’ Department is going to do about the fact that totally Crooked Hillary, AFTER receiving a subpoena from the United States Congress, deleted and ‘acid washed’ 33,000 Emails? No justice!”

And on Saturday, amid reports that FBI Deputy Director Andrew McCabe — a frequent Trump target — intended to retire, the president tweeted, “How can FBI Deputy Director Andrew McCabe, the man in charge, along with leakin’ James Comey, of the Phony Hillary Clinton investigation (including her 33,000 illegally deleted emails) be given $700,000 for wife’s campaign by Clinton Puppets during investigation?”

“The irony is most politicians would recognize that perpetuating silence post-firing would have been the most effective course,” said Jacob Frenkel, a Washington defense lawyer and former prosecutor.

In the event charges are brought or impeachment proceedings are begun, that kind of inconsistent messaging would present “not just entertaining fodder for cross-examination” but also material that could be used to challenge a witness’s credibility, Frenkel said.

But by the same token, the evolving messaging could oddly benefit Trump by making it difficult for prosecutors to attach any one motive or reason — such as a desire to shut down the Russia investigation — for Comey’s firing.

“Once you start picking on one tweet or one message, then it becomes, ‘What about this tweet or that message?’ You’re constantly having competing messages,” Frenkel said.