A Republican senator who exposed one of President Trump’s judicial nominee’s lack of legal smarts got an unexpected reaction from the often-combustible commander-in-chief — a pat on the back.

Trump phoned Louisiana Sen. John Kennedy over the weekend and told him to just do his job when the administration sends an unqualified nominee for Senate confirmation, he said Monday.

“The president and I get along fine, and he has told me, he said, ‘Kennedy, when some of my guys send somebody over who’s not qualified, you do your job,’ ” the senator told WWL-TV.

“And I said, ‘Thank you, Mr. President.’ And I intend to do that.”

In a viral video viewed more than 8 million times, Kennedy put the screws to Matthew Petersen, a Federal Election Commission lawyer and nominee for a federal judgeship in the nation’s capital.

In the cringe-worthy exchange during a Senate Judiciary Committee on Thursday, Kennedy exposed Petersen’s lack of courtroom experience and unfamiliarity with many basic legal principles that even most law students would know.

“The president called me the day before yesterday. He doesn’t interview these guys. He has a staff do it. And he said, ‘Kennedy, I think you’re right,’ ” the senator said.

Kennedy told the station that Petersen was “really smart” and a “decent guy,” Politico reported.

“But just because you’ve seen ‘My Cousin Vinny’ doesn’t qualify you to be a federal judge. And he has no litigation experience. And my job on the Judiciary Committee is to catch him. I would strongly suggest he not give up his day job,” he said.

An embarrassed Petersen admitted he was not a typical nominee.

“I understand that the path that many successful district court judges have taken has been a different one than I’ve taken,” Petersen told Kennedy.