The nation's biggest cities are preparing to lock horns with the Trump administration over undocumented immigrants. Here's everything you need to know:

What is a sanctuary city?
The term loosely applies to about 400 cities, counties, and states across the U.S. that limit local law enforcement cooperation with federal immigration officials. These jurisdictions range from sprawling metropolises like Los Angeles and Boston to smaller counties in rural Oregon and Kansas. These communities have varying policies: Most do not permit police to inquire about a person's immigration status, and some do not turn over undocumented immigrants to federal officials even if they're arrested. President Trump argues that sanctuary cities have become safe havens for criminals, and in January signed an executive order vowing to strip such jurisdictions of federal funding if they refuse to cooperate with federal immigration officials. That move has set up a legal showdown between the Trump administration and "every major city in the U.S.," says Rahm Emanuel, mayor of Chicago — one of at least three dozen sanctuary cities that have openly vowed to defy Trump. "This is not the battle they want to take on."

When did sanctuary cities appear?
The vast majority of sanctuary cities adopted their policies in protest of a Bush-era deportation program known as Secure Communities. That program automatically sent the fingerprints of people booked into local jails to U.S. Immigration and Customs Enforcement (ICE), allowing ICE to target and deport immigrants who had committed only minor crimes, such as traffic offenses. Some cities argued that their police were being turned into proxy immigration agents, damaging community trust, and refused to cooperate. That resistance continued during the Obama administration, which sought to deport those charged with serious crimes. When Trump ran for president, he vowed to crack down on sanctuary cities, making the tragic case of Kate Steinle a centerpiece of his campaign.

What happened to Steinle?
The 32-year-old was shot dead by a stray bullet in July 2015 while walking along San Francisco's Fisherman's Wharf. Steinle's suspected killer, Juan Francisco Lopez-Sanchez, was an illegal immigrant who had been convicted of seven felonies — most of them drug-related — and deported back to Mexico five times. He had re-entered the country and was being held by the San Francisco Sheriff's Department over a decades-old marijuana charge. ICE asked the sheriff's office to notify them when Lopez-Sanchez was released — but San Francisco, a sanctuary city, let Lopez-Sanchez walk free without providing that notice. Three months later, he fired the bullet that killed Steinle. Trump called the shooting "a senseless and totally preventable act of violence," and campaigned with a group of women he called "Angel Moms," whose relatives had been killed by undocumented immigrants.

What does Trump's order do?
The executive measure threatens to withhold all federal funds "except as mandated by law" from jurisdictions that fail to comply with federal immigration law. Republican lawmakers and other sanctuary city opponents argue that local jurisdictions don't get to pick and choose which federal laws they enforce, and that by rejecting more than 17,000 detention requests from ICE between January 2014 and September 2015, sanctuary cities were sheltering criminals. Trump's approach would "finally put federal executive action on the side of the victims and potential victims of crime," says Roy H. Beck, head of anti-immigration advocacy group NumbersUSA.

How have sanctuary cities responded?
They contend that Trump's order is unnecessary and counterproductive and have vowed to fight it. Most sanctuary cities already approve ICE detention requests if the immigrant has a history of serious or violent crime. Police groups also argue that sanctuary policies actually make a city safer, by allowing the country's 11 million undocumented immigrants to report crimes and work with police without the fear of deportation. "We're the melting pot of the world," says Capt. Jeff Scroggin, spokesman for the Los Angeles County Sheriff's Department. "The most important thing we strive to do is to build enough trust so that residents provide information that makes this community safer." In 2015, sanctuary cities experienced 654 fewer crimes per 100,000 residents than non-sanctuary cities — a crime rate that's 15 percent lower.

What happens now?
Trump's executive order seeks to bring sanctuary cities to heel by stripping them of federal funding, which can make up 25 percent of a city's total budget. A major legal battle will now ensue. Cities will rely on two Supreme Court decisions: the 1997 Printz v. United States ruling, in which the late Justice Antonin Scalia wrote that the federal government is prohibited from "commandeering" state and local officials to enforce its laws, and a 2012 ruling that struck down an enforcement mechanism in ObamaCare's Medicaid expansion. "It's very easy to campaign that the king is going to wave his scepter and somehow take away federal funding," says David Narkewicz, mayor of Northampton, Massachusetts, a sanctuary city. "But this isn't the campaign anymore. This is a president who functions in a larger government — a government of laws."

The 'name-and-shame' list
Trump's executive measure on sanctuary cities includes another striking feature: It orders the Department of Homeland Security to publish a weekly "comprehensive list of criminal actions committed by aliens." Trump's name-and-shame list, as it's called by critics, would reveal the identities of illegal immigrants released back into their communities by sanctuary cities, and their specific crime. The goal is to pressure sanctuary jurisdictions to accept more detention requests. Opponents say the list would serve only to stigmatize undocumented immigrants, who are about half as likely to be incarcerated as native-born citizens, according to census data. But Hans von Spakovsky of the conservative Heritage Foundation contends that the rate of crime among immigrants is irrelevant. "The point is that every crime that is committed by someone who is here illegally is a crime that would not occur if they weren't in the country," von Spakovsky said. A public list of crimes, he said, would be "a very important piece of transparency."