WASHINGTON — The FBI agents who raided the office of President Donald Trump's personal lawyer Monday were looking for records about payments to two women who claim they had affairs with Trump, and information related to the publisher of The National Enquirer's role in silencing one of the women, several people briefed on the investigation said.

The search warrant carried out by the public corruption unit of the New York City federal attorney's office seeks information about Karen McDougal, a former Playboy model who claims she carried on a nearly yearlong affair with Trump shortly after the birth of his son in 2006. McDougal was paid $150,000 by American Media Inc., The Enquirer's parent company, whose chief executive is a friend of Trump's.

Agents were also searching the office and hotel room of the lawyer, Michael D. Cohen, for information related to Stephanie Clifford, better known as Stormy Daniels, who says she also had sex with Trump while he was married. Cohen has acknowledged that he paid Clifford $130,000 as part of a nondisclosure agreement to secure her silence just days before the 2016 presidential election.

Cohen's lawyer, Stephen Ryan, on Monday called the raids "inappropriate and unnecessary." In an email on Tuesday, he referred back to that statement.

American Media released a statement saying that the company "has, and will continue to, comply with any and all requests that do not jeopardize or violate its protected sources or materials pursuant to our First Amendment rights." The statement did not say whether it had received such a request.

In a tweet Sunday before the raid, Cohen quoted an author who said that "a person who deserves my loyalty receives it" and added that "I will always protect our POTUS realDonaldTrump."

Trump has been dogged for months by accusations that women with whom he allegedly had affairs were paid to keep quiet before the election — charges that the White House has repeatedly said he denies. In a brief statement last week on Air Force One, the president said he did not know about the $130,000 payment to Clifford, referring questions about it to Cohen.

But the raids Monday suggest that the political challenges for the president are becoming serious legal issues, as criminal investigators dig into Cohen's activities, including, potentially, his communications with the president about the payments.

McDougal has claimed that she had a 10-month affair with Trump 12 years ago, saying on CNN recently that she was intimate with him multiple times during what she described as a consensual affair. American Media, which is owned by David J. Pecker, agreed to pay McDougal $150,000 for the rights to her story in August 2016 after Trump secured the Republican nomination, but did not publish it in a practice known as "catch and kill."

Clifford, a pornographic film star who told her story on CBS's "60 Minutes" last month, is aggressively challenging the nondisclosure agreement she agreed to in October 2016, claiming that it is void because Trump never signed the document. Michael Avenatti, her current lawyer, has filed motions to have Trump deposed in the case.

It is unclear exactly why the New York investigators are examining the payments. But critics of the president have claimed that they amount to illegal campaign contributions — from Cohen and American Media — to the president's campaign because they helped Trump win the White House by keeping politically damaging stories out of public view.

The FBI also searched for records related to Cohen's taxicab business, apparently a separate line of inquiry unrelated to Trump. Cohen is a longtime owner of taxi medallions, at one point operating a fleet of more than 200 cabs in New York City.

The raids heightened the sense of anxiety inside the White House and around Washington as the president reacted to the news by lashing out at his top law enforcement officials Monday evening. Trump called the court-authorized raids an "attack on our country" — unusually harsh language that he has not used to describe Russia's attempts to influence a U.S. election using hacking and propaganda.

Rod Rosenstein, the veteran Republican prosecutor hand-picked by Trump to serve as deputy attorney general, personally signed off on Monday's FBI decision to raid the office of Cohen, a longtime confidant of Trump, several government officials said.

The early-morning searches enraged Trump, associates said, setting off a public tirade Monday evening that continued in private at the White House as the president fumed about whether he should fire Rosenstein.

As Trump has stewed over the developments, he has cast blame in many directions. Publicly, he has expressed frustration with his attorney general and deputy attorney general. Privately, people close to the president said, he has also blamed Cohen for publicly acknowledging the payments to Clifford.

The episode has deeply unsettled White House aides, Justice Department officials and lawmakers from both parties, who believe the president may use it as a pretext to purge the team leading the investigation into Russia's meddling in the 2016 election.

Searching a lawyer's files is among the most sensitive moves federal prosecutors can make as they pursue a criminal investigation. Rosenstein's personal involvement in the decision signals that the evidence seen by law enforcement officials was significant enough to convince the Justice Department's second-in-command that such an aggressive move was necessary.

Trump's advisers have spent the last 24 hours trying to persuade the president not to make an impulsive decision that could put the president in more legal jeopardy and ignite a controversy that could consume his presidency, several people close to Trump said. The president began Tuesday morning with a pair of angry tweets, calling the raids "A TOTAL WITCH HUNT!" and venting that "attorney–client privilege is dead!"

Trump has long been mistrustful of Rosenstein, who appointed special counsel Robert Mueller, and now oversees his investigation into Trump's campaign and possible obstruction of justice by the president. In his remarks Monday night, the president lashed out at Rosenstein for having "signed a FISA warrant," apparently a reference to the role Rosenstein played in authorizing the wiretap of a Trump associate in the Russia inquiry.

Trump considered firing Rosenstein last summer. Instead, he ordered Mueller to be fired, then backed down after the White House counsel refused to carry out the order, The New York Times reported in January. Trump is now again telling associates that he is frustrated with Rosenstein, according to one official familiar with the conversations.

While Rosenstein must sign off on all moves that Mueller makes, that is not necessarily the case for searches — such as this one — that are carried out by other federal law enforcement offices. Justice Department regulations require prosecutors to consult with senior criminal prosecutors in Washington — but not necessarily the deputy attorney general — before conducting a search of a lawyer's files.

The involvement of Rosenstein and top prosecutors in New York in the raid of Cohen's office makes it harder for Trump to argue that his legal problems are the result of a witch hunt led by Mueller. In addition to Rosenstein, all of the top law enforcement officials involved in the raid are Republicans: Mueller; Christopher Wray, the FBI director; and Geoffrey Berman, the interim U.S. attorney in New York.

While Trump is focused for the moment on Rosenstein, many of the president's advisers and allies are fearful that the president also intends to fire Mueller in an attempt to end the Russia investigation. Asked by reporters Monday night whether he intends to do so, Trump said, "We'll see what happens."

"But I think it's really a sad situation when you look at what happened," the president added. "And many people have said you should fire him. Again, they found nothing and in finding nothing, that's a big statement."

The prospect that Trump might fire Mueller was met with fierce responses from Democrats and some Republicans, who warned that such a move would be disastrous for the White House.

Sen. Chuck Grassley, R-Iowa, chairman of the Judiciary Committee, said Tuesday on Fox Business Network that "it would be suicide for the president to want to talk about firing Mueller."

Rep. Nancy Pelosi of California, the top Democrat in the House, on Monday called Trump's attacks on Mueller and his team a "grave reminder of his utter contempt for the rule of law."

The raids are also likely to complicate Trump's negotiations with Mueller over the terms of a possible interview. Trump's lawyers have warned that such an interview would be incredibly risky, but Trump had been confident in his ability and was eager to sit for an interview. People close to the president said the raids could change that thinking.

The president has for months been harshly critical of Attorney General Jeff Sessions for having recused himself in the Russia investigation. Trump renewed that criticism Monday night, saying that "he made what I consider to be a very terrible mistake for the country, but you'll figure that out."

As the president's attacks became more severe over the past months, top Justice Department officials quietly worried about what to do should Trump fire the special counsel or one of his top officials. They chose to band together in a public show of solidarity in late February, when Sessions dined with Rosenstein and Noel J. Francisco, the solicitor general who would oversee the Russia investigation should Rosenstein be fired.