Rudy Giuliani said Wednesday night that President Trump repaid personal attorney Michael Cohen for a $130,000 payment to porn star Stormy Daniels.

Giuliani, who recently joined the president’s legal team, appeared to contradict Trump’s own statements aboard Air Force One last month, when he told reporters he was not aware of the payment and didn’t know where ­Cohen had gotten the money.

Giuliani told Fox News host Sean Hannity, “[They] funneled [the money] through a law firm and then the president repaid.”

But while Giuliani said Trump actually made the payment, the ex-mayor also said it “is going to turn out to be perfectly legal” because “that money was not campaign money.”

“Trump didn’t know about the specifics [of the agreement], as far as I know,” Giuliani said later.

“But he did know about the general arrangement that Michael would take care of things like this, like I take care of things like this for my clients. I don’t burden them with every single thing that comes along.”

Daniels was paid just days before the 2016 election in exchange for her silence about an alleged 2006 tryst with Trump.

The source of the $130,000 has been at issue since it might violate campaign-finance laws.

Giuliani, however, told The New York Times Wednesday night that he had documentation that the payment came from Trump personally.

“That removes the campaign-finance violation,” Giuliani said. “Some time after the campaign is over, they set up a reimbursement, $35,000 a month, out of his personal family account.”

He also said Trump paid Cohen a total of $460,000 or $470,000, though it was not clear what the additional money was for. Giuliani said Trump knew what the ex-mayor was going to say in the Fox interview.

The president has denied having sex with Daniels.

Cohen’s Manhattan office was raided last month by federal agents from the US Attorney’s Office. Agents seized documents related to the $130,000 payment.

The investigation is separate from special counsel Robert Mueller’s probe into Russian meddling in the 2016 election.

Daniels’ lawyer, Michael Avenatti, late Wednesday night called Giuliani’s statements “a stunning revelation.”

“Mr. Trump evidently has participated in a felony and there must be serious consequences for his conduct,” Avenatti said on CNN.

With AP