The White House on Thursday said President Trump learned of domestic abuse allegations against top aide Rob Porter only a day before he resigned.

Speaking at a press briefing that was delayed for two hours and 42 minutes, deputy White House spokesman Raj Shah said the FBI’s background check had not been completed, and that Porter was serving as chief of staff John’s Kelly’s senior aide with only an interim security clearance.

Shah said Trump only learned about the domestic violence allegations made by Porter’s two ex-wives on Tuesday evening — but would not say when Kelly learned of them.

Shah also argued that the allegations had not been proven — suggesting that it would have been premature to can Porter until his background probe was complete.

“It’s important to remember that Rob Porter has repeatedly denied these allegations and done so publicly,” Shah said, adding that the incidents “took place long before he joined the White House.”

But, he admitted, “We all could have done better over the last few hours or last few days in dealing with this situation.”

Meanwhile, lawmakers from both sides of the aisle ripped Kelly following reports that he knew for months that Porter was an accused wife-beater and did nothing about it.

Louisiana GOP Sen. John Kennedy said Kelly blew it by keeping Porter aboard so long as his staff secretary.

“If you want to serve the public, particularly as a member of a president’s staff, I don’t care who you are, you can’t beat the hell out of your spouse,” Kennedy said on CNN.

The former Marine general also took it on the chin from Montana Democratic Sen. Jon Tester, who said Porter should have been “shipped out the door” as soon as the White House learned about the allegations of domestic abuse last fall.

“If John Kelly is covering this up, he needs to be held accountable, no if, ands or buts about it. He better have a really good reason. Otherwise, he’s gone, too,” Tester said. “I have no use for anybody who beats their spouse, none whatsoever. If the White House knew about it months ago, shame on them.”

Peter Wehner, who served in various capacities in the Reagan White House and both Bush administrations, called Kelly’s defense of an accused wife-beater “stunning.”

“To have a chief of staff defend the integrity of a person who’s been credibly accused of being a wife-beater is just stunning . . . and unconscionable,” Wehner told the Washington Post.

“What he’s done as chief of staff doesn’t undo what he did as a heroic war figure, but it diminishes him as a person, and that’s regrettable.”

But conservative North Carolina Rep. Mark Meadows said Kelly should get a pass.

“I don’t see the confidence in Gen. Kelly being diminished within the West Wing,” he said.

Before the allegations were revealed Tuesday, the White House scrambled to defend Porter, who later resigned.

Hope Hicks, Trump’s communications director and Porter’s latest gal pal, helped draft a statement of support from Kelly, who hailed the accused wife abuser as a “man of true integrity and honor.”

But after a furious backlash slamming the former general for his tone-deaf response, Kelly changed his tune and said he was shocked by the charges.

Shah said Kelly issued the stronger statement after seeing a photo of one of Porter’s ex-wives with a black eye.

“I was shocked by the new allegations released today against Rob Porter. There is no place for domestic violence in our society,” Kelly said Wednesday night, though it was unclear what “new allegation” he was referring to.

But Kelly still defended his pal.

“I stand by my previous comments of the Rob Porter,” he said.

Trump — who has faced allegations of sexual assault or misconduct from more than a dozen women, and who was caught on tape bragging about groping women’s genitals — has remained mum on Porter.

But administration spokeswoman Sarah Sanders said Trump had “confidence in his performance.”

While Trump has not spoken publicly about the allegations, Shah said the president found them troubling.

Porter’s ex-wives said they were subjected to physical, verbal and emotional abuse.

His first wife, Colbie Holderness, told the paper, which published the photo of her with the black eye, that Porter choked and punched her during their five years of marriage.

His second wife, Jennifer Willoughby, said Porter once dragged her naked and wet from the shower to yell at her while on vacation.