Washington CNN  — 

Though President Donald Trump on Friday publicly revealed his proposal to transport and release undocumented immigrants into sanctuary cities, 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 DHS.

The reasons the President has publicly stated for the policy proposal – one that senior administration officials tell CNN he has been pushing for behind the scenes for months – are decidedly not related to the DHS mission statement.

“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 tweeted Friday. “The Radical Left always seems to have an Open Borders, Open Arms policy – so this should make them very happy!”

Mitnick, whose insistence that immigration policies and actions fall within the confines of the law, has aroused the ire of Trump, top aide Stephen Miller and other immigration hardliners in the White House, made it clear in his legal guidance that the “mission related rationale” for transporting undocumented immigrants did not include political retaliation.

While the department has the legal authority to use its budget to move and release migrants to locations far from where they were apprehended, detained or processed, officials could only do so in a way consistent with what the comptroller general had referred to as “an authorized agency purpose,” Mitnick wrote. Examples of this that he cited included providing appropriate health care, fulfilling a transfer request or relieving facility overcrowding.

Moreover, Mitnick noted, such a proposal could be self-defeating: transporting an undocumented immigrant to a remote location where he had no ties would increase the likelihood that he would become a flight risk and not attend his removal proceedings.

Challenging the White House to provide a “strong mission-related rationale” for the proposal, Mitnick noted that even if they could provide such rationales, the new policy would prompt a “litigation risk” for the US government for violating the “due process” rights of the undocumented immigrants by moving them to places where they have no community, family ties, or employment opportunities.

The move would have created grounds for a migrant to claim hardship and increasing the likelihood of habeas litigation accusing the US government of ordering releases that were not “reasonable,” he argued.

Neither the White House nor the Department of Homeland Security responded to a request for comment.

Senior administration officials tell CNN that Mitnick’s legal analysis was shared with the White House and DHS lawyers spoke with the White House Counsel’s Office within days to explain their reasoning.

“Once the lawyers explained it, the issue was ultimately dropped,” an official said.

That is, until it broke on Thursday and the President took to Twitter to defend it and bring it back to life on Friday.