President Donald Trump repaid his lawyer Michael Cohen the $130,000 that Cohen paid porn star Stormy Daniels days before the 2016 election for her silence about an alleged affair with Trump — and the president said Thursday morning that the reimbursement didn't come from campaign funds and was perfectly appropriate.

Appearing Wednesday night on Fox News' "Hannity," Rudy Giuliani, the former New York mayor and ex-U.S. attorney whom Trump hired to join his legal team last month, revealed for the first time that Trump had paid back the money to Cohen, who had said previously that he paid Daniels out of his own pocket and without Trump's knowledge.

"That was money that was paid by his lawyer" to Daniels, Giuliani told Sean Hannity of Cohen's $130,000 payment. "The president reimbursed it over several months," Giuliani said, adding that the payment didn't constitute an illegal campaign contribution, as Democrats and other critics of Trump have contended, because it didn't come from Trump campaign funds.

Trump took to Twitter Thursday morning to affirm Giuliani's claims, posting that Cohen "received a monthly retainer, not from the campaign and having nothing to do with the campaign, from which he entered into, through reimbursement, a private contract between two parties, known as a non-disclosure agreement, or NDA."

Trump called such agreements "very common among celebrities and people of wealth."

"The agreement was used to stop the false and extortionist accusations made by her about an affair ... despite already having signed a detailed letter admitting that there was no affair," the president tweeted. "Prior to its violation by Ms. Clifford and her attorney, this was a private agreement. Money from the campaign, or campaign contributions, played no role in this transaction."

Trump had told reporters in April that he had no knowledge of Cohen having paid Daniels.

On Thursday, White House Press Secretary Sarah Huckabee Sanders, when pressed about her boss' April denial, responded that the payment was "information the president didn't know at the time but eventually learned."

Cohen and White House aides have denied that Trump had an affair with Daniels, who claims she had a one-night sexual encounter with Trump in 2006.

"I am absolutely speechless at this revelation," Daniels' attorney, Michael Avenatti, said Wednesday night.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"The American people have been lied to about this agreement, about the $130,000," Avenatti said in an interview on MSNBC's "The Last Word With Lawrence O'Donnell."

"There are going to be serious charges that may result from that," he said, adding, "Make no mistake about it: Justice is going to be served."

Giuliani, for his part, said on Wednesday night that the payment is "going to turn out to be perfectly legal."

"That money was not campaign money," he said of Trump's reimbursement to Cohen. "Sorry — I'm giving you a fact that you don't know. It's not campaign money — no campaign finance violation."

Giuliani added, during an appearance Thursday morning on Fox News, that the money paid to Daniels was intended to protect Trump's family.

"This was for personal reasons. This was, the president had been hurt personally. Not politically, personally so much, and the first lady, by some of the false allegations, by one more false allegation, six years old, that I think he was trying to help the family," Giuliani said on "Fox and Friends."

Referring to Cohen, Giuliani said, "For that, the man is being treated like some kind of villain, and I think he was just being a good lawyer and a good man."

On Wednesday night, after his initial appearance on "Hannity," Giuliani told The New York Times that after the presidential campaign, Cohen was reimbursed $460,000 or $470,000 in $35,000-a-month installments through a Trump family account for having "settled several problems" for the president.

Giuliani said he was "not clear” whether Trump was aware of the payments to Daniels when they were made, according to The Times.

"I don't think he did (know) until now," Giuliani said. "That removes the campaign finance violation, and we have all the documentary proof for it."

In another interview on Wednesday night, with The Washington Post, Giuliani said the president was "very pleased" he had made public the additional details of the payments on Fox News and that he and Trump had discussed the plan for the revelation in advance.

"He was well aware that at some point when I saw the opportunity, I was going to get this over with," Giuliani said, responding to a question about whether Trump was "angry" with him for the revelation.

Meanwhile, Norm Eisen, chairman of Citizens for Responsibility and Ethics, a nonprofit group that has filed a complaint with the Justice Department over the payment to Daniels, suggested Wednesday night on Twitter that Trump may have broken the law "by failing to disclose the loan from Cohen on his federal presidential financial disclosures."

Whoa, Rudy may just have proven our @CREWcrew complaint that Trump broke the law by failing to disclose the loan from Cohen on his federal presidential financial disclosures. Those are filed under criminal penalty for false statements, 18 USC 1001. https://t.co/1W1BP4RvIT — Norm Eisen (@NormEisen) May 3, 2018

As recently as last month, Trump denied that he had been aware at the time that Cohen had paid Daniels.

Speaking to reporters aboard Air Force One in April, the president said not only that he hadn't known about the payment but also that he didn't know where the money had come from.

Asked why Cohen paid Daniels, Trump replied: "You'll have to ask Michael Cohen. Michael is my attorney. You'll have to ask Michael."

Daniels has sued the president to void the nondisclosure agreement arranged by Cohen, alleging that it is invalid because Trump never signed it. She has described it as a "hush" money agreement intended to buy her silence before Election Day in 2016.

Meanwhile, Giuliani also contradicted Trump's initial assertions in May 2017 that the FBI's investigation of alleged collusion between Russia and the Trump campaign had nothing to do with his decision to fire FBI Director James Comey.

Trump has said that "when I decided to just do it I said to myself, I said: 'You know, this Russia thing with Trump and Russia is a made-up story. It's an excuse by the Democrats for having lost an election that they should’ve won.'"

Giuliani, however, said the president fired Comey because "Comey would not, among other things, say that (Trump) wasn't a target of the investigation."

The distinction is important because Attorney General Jeff Sessions signed off on Comey's dismissal even though he had recused himself from involvement in the Russia investigation, raising the question of whether the attorney general violated his recusal.