A Department of Homeland Security official dismissed a report by The New York Times on Friday alleging that the president pressured Acting DHS Secretary Kevin McAleenan to close the southern border and offered him a pardon if the need arose.

A spokesperson with the department confirmed to Fox News on Friday that Trump has never “indicated, asked, directed or pressured the acting secretary to do anything illegal,” and said McAleenan would never “take actions that are not in accordance with our responsibility to enforce the law.”

The Times, citing three sources familiar with the conversation, said Trump “urged” McAleenan to close the southwestern border. In the event of legal troubles, the story went, Trump said he'd pardon him.

NIELSEN RESIGNS AS DHS SECRETARY AFTER WHITE HOUSE MEETING WITH TRUMP

The conversation was said to have taken place before Trump announced on Sunday that McAleenan, U.S. Customs and Border Protection (CBP) commissioner at the time, would replace Kirstjen Nielsen, who resigned.

Trump had made threats to close the border but after his trip to Calexico, Calif., last week, he seemed to back down.

The Times report, however, alleged that the president privately pushed for the matter behind closed doors and was told by Nielsen that doing so would be illegal. Two days later she announced she would be leaving her post.

The report stated that Trump “encouraged” McAleenan to disregard his predecessor’s warning and move forward with his request.

CLICK HERE TO GET THE FOX NEWS APP

Sources told the Times that it was unclear if Trump’s alleged remarks were meant as a joke.

McAleenan is a longtime border officer, who previously practiced law in California and is seen by some as potentially taking the job of DHS secretary permanently.

Fox News’ Kristin Brown and Frank Miles contributed to this report.