Washington CNN  — 

President Donald Trump told Customs and Border Protection Commissioner Kevin McAleenan he would grant McAleenan a pardon if he were sent to jail for having border agents block asylum seekers from entering the US in defiance of US law, senior administration officials tell CNN.

Trump reportedly made the comment during a visit to the border at Calexico, California, a week ago. It was not clear if the comment was a joke.

Two officials briefed on the exchange say the President told McAleenan, since named the acting secretary of the Department of Homeland Security, that he “would pardon him if he ever went to jail for denying US entry to migrants,” as one of the officials paraphrased.

The White House referred CNN to the Department of Homeland Security. A DHS spokesman told CNN, “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.”

Trump denied reports he offered pardons in a tweet late Friday night.

The exchange came amid threats by the President to close the border in response to a steep uptick of migrants at the border. In March, there were approximately 92,000 arrests of undocumented migrants for illegal entry on the southern border, up from 37,390 last March, according to CBP.

During his visit to Calexico last Friday, Trump said on camera: “We’re full, our system’s full, our country’s full – can’t come in! Our country is full, what can you do? We can’t handle any more, our country is full. Can’t come in, I’m sorry. It’s very simple.”

Behind the scenes, two sources told CNN, the President told border agents to not let migrants in. Tell them we don’t have the capacity, he said. If judges give you trouble, say, “Sorry, judge, I can’t do it. We don’t have the room.”

RELATED: Trump pushed to close El Paso border, told admin officials to resume family separations and agents not to admit migrants

After the President left the room, agents sought further advice from their leaders, who told them they were not giving them that direction and if they did what the President said they would take on personal liability. You have to follow the law, they were told.

Trump has grown frustrated by the number of migrants apprehended at the southern border, placing blame on Democrats and the nation’s immigration laws. On Friday, the President said he’s considering releasing immigrants into so-called sanctuary cities in part to retaliate against Democrats, undercutting earlier denials from his own administration officials.

“Due to the fact that Democrats are unwilling to change our very dangerous immigration laws, we are indeed, as reported, giving strong considerations to placing Illegal Immigrants in Sanctuary Cities only,” Trump said on Twitter. “The Radical Left always seems to have an Open Borders, Open Arms policy – so this should make them very happy!”

Yet the White House received legal guidance months ago that such a policy would run afoul of the law, open the administration to lawsuits, and ultimately undermine the President’s desire to deport undocumented immigrants.

In February, according to documents obtained by CNN, the general counsel for the Department of Homeland Security, John Mitnick, told the White House in writing that such a move could only be done if there was a “strong, mission-related rationale” pertaining to the responsibilities of the department.

CNN’s Priscilla Alvarez contributed to this report.