President Donald Trump on Tuesday accused cities failing to cooperate with US immigration authorities of endangering Americans by releasing "thousands of criminal aliens" who - he says - should be deported.

Trump met at the White House with lawmakers and federal and state officials to discuss sanctuary cities - some 200 US cities and counties that do not allocate funds to pursuing illegal immigrants and refuse to inform federal authorities of the immigration status of people who are detained or arrested by law enforcement.

"In many cases they are very bad actors. We have gang members, we have predators, rapists, killers - a lot of bad people," Trump said, adding that sanctuary cities are "causing a lot of problems for this country" by protecting "bad actors" and even aiding "hardened criminals" at the expense of "innocent Americans."

"It's so basic. It's called law and order and safety and we're going to have it in our country," Trump said. "Sanctuary cities are dangerous and we're going to take care of the problem."

The designation sanctuary cities includes major US cities such as New York and Chicago, as well as the entire state of California.

Trump said that "California put innocent Americans at the mercy of hardened criminals, hardened murderers in many cases," adding that Democrat lawmakers have opposed bills to withhold federal funds from sanctuary cities.

Those funds - for example - are used to upgrade the equipment available to police, but Trump tried to halt the distribution of that money via an executive order that last October a federal judge in Chicago nullified by ruling that the president cannot decide on municipal budgets.

"Democrats' priority is to protect criminals, not to do what's right for our country," Trump said. "My priority and the priority of my administration is to serve, protect and defend the citizens of the United States."

Trump said he was sure that soon a bill would move forward in Congress that would allow federal funds for the affected jurisdictions to be curtailed, a piece of legislation that has been pushed by some of the Republican lawmakers invited to the White House on Tuesday including Sen. Tom Cotton of Arkansas and Rep. Michael McCaul of Texas.

US Attorney General Jeff Sessions, who also attended the roundtable, said that what sanctuary cities are doing "is a knife in the heart of the partnerships and cooperative relationships between our state and local officers."