President Trump lashed out Tuesday at prosecutors for the FBI raids of his longtime personal attorney’s Manhattan office, home and hotel room, claiming that it signals an end of attorney-client privilege.

“Attorney–client privilege is dead!” the president said on Twitter.

Moments later, he fired off another brief early morning tweet: “A TOTAL WITCH HUNT!!!”

On Monday, FBI agents seized records of lawyer Michael Cohen’s clients and personal finances. According to a person familiar with the inquiry, among the records taken were those related to a 2016 payment Cohen made to adult-film star Stormy Daniels, who said she had a sexual encounter with Trump in 2006.

The raids were part of an investigation referred by special counsel Robert S. Mueller III to federal prosecutors in New York. Cohen is under federal investigation over possible bank fraud, wire fraud and campaign-finance violations, three people with knowledge of the case have told The Washington Post.

Trump ignored questions about Mueller shouted by reporters during a Tuesday afternoon meeting at the White House with Tamim bin Hamad al-Thani, the emir of Qatar.

Patrick Cotter, a former federal prosecutor who practices law in Chicago, said Trump was “mistaken” in his assessment that attorney-client privilege is dead.

“As a lawyer, you never like to hear about lawyers getting searched,” Cotter said. “It’s a scary scenario, but the reality is, there is a procedure for this.”

Several lawyers noted that public statements by Trump and Cohen may have significantly aided federal prosecutors’ legal arguments to justify searching the lawyer’s office, home and hotel room.

Cohen has said that he arranged the $130,000 payment to Daniels and that Trump was unaware of it.

Then, late last week, Trump said he did not know of the payment.

Because both the lawyer and the client insisted that Trump had no idea that Cohen had made the payment, they cannot assert that those activities were protected by attorney-client privilege, legal experts said.

“At that point, anything to do with that entire incident is, I would argue, not attorney-client privilege,’’ Cotter said. “If I were a prosecutor hearing both the lawyer and the client say the client had no awareness whatsoever of that, I would now feel very confident going to a judge to seek that material.”

It is rare, but not unprecedented, for federal prosecutors to execute search warrants on lawyers’ offices.

Justice Department procedures call for a filter or “taint” team to screen all the seized documents in such cases, separating out material protected by attorney-client privilege so that it would not be shared with investigators.

Material that is not protected by the privilege but is relevant to the documents being sought in the search is turned over to the investigative team.

In law enforcement circles, agents sometimes refer to this as a “dirty” team and a “clean” team. If the “taint” team finds documents that indicate a lawyer participated or even unwittingly facilitated some type of fraud, then the attorney-client privilege would no longer apply and that information would also be turned over to investigators.

Cotter noted that there is a third, often unnoticed category of lawyer-client communications that is not covered by the privilege. If there are conversations in which the lawyer is not providing advice on legal matters but that still involve topics of interest to investigators, that material can, in some cases, also be turned over to investigators.

At the same time, it is likely that Cohen’s attorney will send New York prosecutors a list of names of clients or people associated with clients, telling the prosecutors that any material related to those individuals is protected by the attorney-client privilege. Cohen and his attorney can also raise objections before a judge if they feel the “taint” team improperly turned over documents that should rightly be protected by the attorney-client privilege.

Among the exceptions to attorney-client privilege is one known as the crime-fraud exception, which exempts communications in furtherance of a contemplated or ongoing crime or fraud.

That was pointed out on Twitter later Tuesday morning by Preet Bharara, a former U.S. attorney for the Southern District of New York, whom Trump fired.

That office, now led by a Trump appointee, approved the raid of Cohen’s office on Monday.

Responding to Trump’s tweet, Bharara wrote: “Long live the crime-fraud exception.”

Trump’s tweets echoed comments he made Monday night to reporters at a dinner with military leaders. At the dinner, he repeatedly called the raid “a disgrace” and said he has been the subject of a long witch hunt.