US President Donald Trump speaks as Acting Commissioner of U.S. Customs and Border Protection Kevin K. McAleenan (2nd R) watches during a meeting at the Customs and Border Protection National Targeting Center in Sterling, Virginia on February 2, 2018.

The New York Times reported that Trump pushed Kevin McAleenan to take that action last week, despite having publicly claimed days beforehand that he was giving Mexico a warning of one year to stop illegal immigration and drugs flowing over its border or face a shutdown of the crossing.

President Donald Trump urged the now-acting secretary of Homeland Security to close the U.S. border with Mexico, and that he would pardon him if he suffered any legal fallout from following Trump's directive, new reports said Friday.

CNN, quoting two senior administration officials, said that during a visit by the president to the border at Calexico, California, Trump told McAleenan, who at the time was commissioner of Customs and Border Protection, that "he would pardon him if he ever went to jail for denying US entry to migrants."

McAleenan has since been named acting secretary of the Department of Homeland Security on the heels of the resignation of Kirstjen Nielsen. She had rebuffed the president's earlier efforts to close the border because it would be illegal.

The White House had no immediate comment when contacted by CNBC.

A Department of Homeland Security spokesman said: "At no time has the President indicated, asked, directed or pressured the Acting Secretary to do anything illegal. Nor would the Acting Secretary take actions that are not in accordance with our responsibility to enforce the law."