Analysis: After weeks of immigration policy struggles, the president's allies think the debate over the agency's future puts him on more favorable political terrain.

President Donald Trump's base voters didn't like it when he beat a retreat on the policy of separating undocumented families at the border. And they were so dead set against "amnesty" provisions in a House immigration bill he backed that he later falsely claimed that he had never lobbied on it.

Overall, Trump has lost so far on his core immigration promises: to build a border wall, force Mexico to pay for it and vastly reduce both legal and illegal migration to the country.

But his allies say he's found a huge political winner, for the midterm elections and his 2020 re-election bid, in the call by some prominent Democrats to "abolish ICE" — the acronym for the U.S. Immigration and Customs Enforcement agency.

"There’s long been division in the Republican Party on the issue of immigration, but the one thing everyone can agree on is the Democrats are crazy for wanting to abolish ICE," said a former Trump White House official who spoke to NBC on the condition of anonymity to discuss the president's strategy.

That helps explain why Trump is turning the fight over detention-policy into a full-blown war over ICE.

From the Trumpworld perspective, it's an easy branding exercise: Democrats are for getting rid of an agency that cracks down on undocumented immigrants; which makes them in favor of open borders; and, in turn, that means they are generally for lawlessness.

Better yet, for Trump, the faces of the policy are Democrats who are widely considered potential 2020 rivals to him, including Sens. Kirsten Gillibrand of New York, Elizabeth Warren of Massachusetts and, to a slightly lesser extent because she hasn't directly called for an end to the agency, Kamala Harris, D-Calif. They're raising their voices just as he is ramping up a barnstorming tour in advance of the midterm elections that is a not-so-dry run for his re-election campaign.

And, best of all for Trump, they did the branding for him. "Abolish ICE" isn't his phrase; it's theirs.

"He has taken the abolish ICE thing, he’s wrapping it around the necks of the Democrats and he views it as his blunt instrument to defeat the Democrats in 2018 and whoever they put up in 2020," the former White House official said. "No doubt about it."

It's not just Trump's campaign that is pushing the issue. The official White House Twitter account slammed Warren and Harris on Monday for their statements on immigration, and the administration is pushing out stories about ICE's law enforcement work.