President Trump’s lawyer Rudolph W. Giuliani sought Friday to clean up a series of comments he had made about a settlement with an adult-film actress who allegedly had a relationship with Trump, backtracking on his previous assertions about what the president knew and why the payment was made.

The cautious wording of the written statement released by Giuliani stood in sharp contrast to his previous two days of wide-ranging television and print interviews in which, according to legal experts, he exposed his client to greater legal risks and might have compromised his own attorney-client privilege with the president.

The former New York mayor startled White House officials and other members of Trump’s legal team by announcing Wednesday that the president had reimbursed his personal lawyer Michael Cohen for a secret $130,000 payment he made in 2016 to actress Stormy Daniels. In several interviews, Giuliani also talked at length about how much Trump paid Cohen and when the reimbursements were made.

Some Trump advisers said they fear that Giuliani may have waived his right to assert that his conversations with the president are private — and that government or private lawyers pursuing lawsuits could now seek to interview him.

The drama instigated by the freewheeling former U.S. attorney — who signed on as Trump’s lawyer just last month — is the latest crisis to hit the president’s legal team, which has weathered numerous departures in recent months as it contends with the special counsel investigation into Russian election interference and a newly revealed separate criminal probe into Cohen.

The most recent shake-up came this week, with the news that Ty Cobb, the White House lawyer dealing with the special counsel, will be replaced by veteran white-collar defense attorney Emmet Flood.

Despite the fallout from his comments, Giuliani still appeared to be in good graces with the president, according to people familiar with his standing. The two men continued to confer privately about how to handle the Daniels matter, without consulting with the White House communications shop or the White House counsel’s office.

In an interview Friday with The Washington Post, Giuliani said Trump was not mad at him. “He says he loves me,” Giuliani said.

For his part, Trump told reporters Friday that Giuliani, who joined the legal team April 19, “just started a day ago” and is “learning the subject matter.”

“He knows it’s a witch hunt,” the president added. “He’ll get his facts straight.”

But Giuliani’s attempt at damage control will probably do little to mitigate the legal problems he has caused, legal experts said.

“The first rule is to shut up, which he is unable to do,” said Stephen Gillers, a law professor at New York University. “False exculpatory statements often come back to bite.”

“Giuliani’s barrage harmed his client,” he added. “He waived the privilege for communications with Trump on the subject of his public statements.”

One close Trump adviser agreed, saying Giuliani had “waived the privilege, big time,” with his public descriptions of his conversations with the president.

Trump initially did not appear concerned about Giuliani’s revelations, telling him Wednesday night that he was “very pleased” with his comments, as Giuliani told The Post that night.

But Friday morning, the two men had a long conversation, during which they decided that a clarification was needed, Giuliani said in an interview Friday evening.

“We wanted to get everyone on the same page,” he said.

In the statement he released, Giuliani insisted that the settlement with Daniels to keep her from disclosing an alleged sexual encounter with Trump in 2006 was made solely “to protect the President’s family.”

“It would have been done in any event, whether he was a candidate or not,” he added in his statement.

That contrasted with comments he made earlier in the week, when he referred to the Daniels settlement in the context of the 2016 presidential campaign.

Appearing Thursday on Fox News Channel, for instance, Giuliani asked viewers to imagine if Daniels had aired her allegations “in the middle of the last debate with Hillary Clinton.”

He added that Cohen “made it go away. He did his job.”

Campaign finance law experts said such remarks by Giuliani may have offered new potential evidence for federal prosecutors in Manhattan who are investigating Cohen.

In his statement, Giuliani also sought to make clear that he spoke in recent interviews about his understanding of events in which Trump had been involved — not about what the president knew at the time.

“My references to timing were not describing my understanding of the President’s knowledge, but instead, my understanding of these matters,” he said.

The distinction is important because if Giuliani had publicly described a private conversation with the president, he might have inadvertently waived attorney-client privilege on that conversation — potentially opening the door for prosecutors to probe further into what was said, legal experts said.

In interviews earlier in the week, Giuliani indicated that he had conferred with the president before he divulged that Trump had reimbursed Cohen.

“He was well aware that at some point when I saw the opportunity, I was going to get this over with,” Giuliani told The Post on Wednesday night, adding that he had discussed the matter with Trump “probably four or five days ago.”

In a subsequent interview with NBC, Giuliani said he told Trump what Cohen had done on his behalf.

“I don’t think the president realized he paid him back for that specific thing until we made him aware of the paperwork,” he said.

Giuliani said the president responded, “Oh my goodness, I guess that’s what it was for.”

Giuliani’s statements were based on a relatively short conversation he had with Trump about the Daniels matter, according to two people familiar with their discussions. Giuliani did not independently delve into the details of the case before he went on the air Wednesday night, they said.

“Rudy followed the client’s wishes without knowing all the facts,” one person said.

Giuliani disputed that, telling The Post on Friday evening that his understanding of the case came from “co-counsel, from reading documents, from conversations I had.”

“It wasn’t all from talking to the president,” he said.

He also offered more details about the repayment arrangements, saying Trump had re­imbursed Cohen by paying him $35,000 a month in 2017 for legal work Cohen did the previous year.

“It was sort of a straight-out bill,” he said. “If he didn’t pay it every month, he paid it many months.”

“The monthly bill was paying down the expenditures. . . . It was not a loan,” Giuliani added. “Some of it was for taxes, some of it was for incidental expenses, it covered things that might come up.”

Giuliani said he did not know whether the president knew the details of the work Cohen performed for him.

“I have not been able to determine that,” he said. “He trusted Michael a lot.”

He said the president’s legal team recently asked a campaign finance lawyer to scrutinize the payment to Daniels, and the lawyer concluded that no laws were broken.

Several legal experts said Giuliani’s expansive statements could spur a lawyer — either a prosecutor or an attorney involved in civil litigation — to seek to compel him to offer testimony about that discussion.

Michael Avenatti, an attorney for Daniels, said he was considering whether to try to seek testimony or other information from Giuliani in a civil case the actress has brought against Cohen and the president.

“We’re still in the process of analyzing what he said, and we may very well make that argument, but we want to be thoughtful and strategic about it,” Avenatti said.

In his statement, Giuliani also said it was “undisputed” that Trump had the constitutional power to fire former FBI director James B. Comey, which he did last year. Trump’s action is among those under scrutiny by Mueller as part of his investigation into possible collusion between the Trump campaign and Russia to influence the 2016 election.

Giuliani appeared to be backing away from an assertion he made earlier this week that the president acted out of frustration that Comey wouldn’t publicly state that the president was not under investigation by the FBI.

That statement raised concerns among some legal experts who said that Giuliani seemed to indicate Comey was fired over the Russia investigation — and that such an admission could further an obstruction-of-justice probe involving the president.

Inside the White House, there is sensitivity among counsel Donald McGahn and others about the Comey firing, an official said, and Giuliani’s comments were seen as “not helpful.”

Senior White House staffers were caught off guard Wednesday by Giuliani’s first appearance on Fox News, when he disclosed that Trump had repaid Cohen. White House press secretary Sarah Huckabee Sanders told reporters Thursday that she had not learned about the repayment until seeing Giuliani on television.

On Friday, a person close to the White House said Giuliani was still not consulting with McGahn or Flood or the press office.

For his part, Trump told associates that he resented media coverage saying he had lied about the Daniels affair after Giuliani revealed the repayment and wanted a statement issued declaring that he had not lied, according to a senior administration official.

Trump’s comments that Giuliani was a “great man” reminded several current and former officials of Trump’s kiss of death: lavishly praising a subordinate just before the person is fired. But a person close to both men said Giuliani and Trump remained on good terms.

Trump also told reporters Friday that if he could be treated fairly, he would “love to speak” to federal prosecutors investigating ties between his campaign and Russia. He said he would do so even over the objections of his lawyers — if he could be convinced that the Russia probe is not a “witch hunt.”

“I would love to speak. I would love to go,” Trump said. “Nothing I want to do more, because we did nothing wrong.”

But, he added, “I have to find that we’re going to be treated fairly. . . . Right now, it’s a pure witch hunt.”

Carol D. Leonnig, Rosalind S. Helderman, Tom Hamburger and Beth Reinhard contributed to this report.