Supporters of California's sanctuary bill prepare to testify in March at the state capitol. (Don Thompson/AP)

Flipping a giant middle finger to President Trump, California is on its way to becoming the first sanctuary state in the nation.

Democratic lawmakers there are moving a bill that would prevent local and state law enforcement agencies from helping the federal government deport undocumented immigrants. (The state Senate passed it last week, and the state Assembly is expected to take it up soon, though Gov. Jerry Brown (D) hasn't said whether he'll sign it.)

Sanctuary cities are one of the most high-profile acts of defiance to a Trump presidency, and the president has expressed a zero-tolerance policy toward them. In his first week in office, Trump signed an executive order declaring that sanctuaries are in violation of federal law and “have caused immeasurable harm to the American people.”

Except it's not as simple as winning the presidency and then putting pen to paper to force California's hand. Trump will run into legal and political challenges if he wants to go to war with California over this issue. His powers in this area could even end up being decided at the U.S. Supreme Court.

We talked to immigration experts on both sides of the issue to see how this potentially epic immigration showdown between California and Trump might unfold — and it could shape what happens in the hundreds of other liberal cities and counties attempting to defy Trump on this.

Step 1a: The Trump administration tries to publicly shame California

Actually, this is already in the works. His executive order requires the federal government to make a list of immigrants these cities and states are protecting and whether any have been charged with crimes. It's an effort to put public pressure on these communities to hand over immigrants who are eligible for deportation. (Most, if not all, of sanctuary jurisdictions have said they will offer up immigrants convicted of violent crimes for deportation.)

The first report, out in March, accused the Philadelphia Police Department of releasing one immigrant who was charged with homicide. But Immigration and Customs Enforcement announced Tuesday it was suspending its weekly report because of inaccuracies.

Step 1b: The Trump administration cuts off grant money to California

Actually, this is already in the works, too. California is on track to lose law enforcement funding as well as federal funds for health care and nutrition for the poor because of a 2014 law that limited the state's cooperation in handing over fingerprints of undocumented immigrants.

In March, Attorney General Jeff Sessions stepped onto press secretary Sean Spicer's podium, faced the cameras and warned cities, counties and California that the Justice Department would withhold billions of dollars if they don't hand over illegal immigrants when asked to do so.

Pulling this financial lever has solved at least one problem for the Trump administration: Under a Republican mayor, Miami-Dade County this year reversed its policy of holding immigrants only if the federal government pays the costs. With its policy reversal, the county preserves some $300 million in federal funds.

But California has clearly calculated that pursuing its policy is more valuable than the money. Which brings us to ...

Step 2: California challenges the withholding of money in court

Ilya Somin, a constitutional law professor at George Mason University, thinks the administration would lose this legal battle. The Supreme Court has long ruled that the federal government can impose conditions on grants only if those conditions are “unambiguously” stated in the grant.

It would take an act of Congress to go back and insert a clause declaring these unrelated law enforcement, health-care and poverty grants deliverable only if jurisdictions hand over their illegal immigrants for deportation when the government asks for them.

The likely vehicle for this lawsuit could be in San Francisco, one of the oldest sanctuary cities in the nation. In March, the city sued the Trump administration for threatening to withhold what it says is $1.2 billion in grants.

If San Francisco wins, that could be a fatal blow to the Trump administration, Somin said. “If California is able to do this and Trump isn't able to do much to prevent them, that will give momentum to other sanctuary cities,” Somin said.

Step 3: The Trump administration sues California

Immigrant rights supporters protest during a Los Angeles City Council committee meeting in March. (Lucy Nicholson/Reuters)

The Department of Justice could sue California and try to block the implementation of this law.

It's never been tried, and the Trump administration would likely have to sue in the same San Francisco-based federal court that unanimously blocked its first entry ban.

But it may be the best chance the administration has, says Jessica Vaughan of the conservative-leaning Center for Immigration Studies. Lower courts have split on whether it is legal for the federal government to require local law enforcement to hand over immigrants.

The California state legislature tried to put the Trump administration on the spot Tuesday in a letter it sent to Sessions: "In its repeated attacks on States, the Administration appears to forget that our system is one of "dual sovereignty between the States and the Federal Government," reads a letter from a team of private leaders headed by former U.S. Attorney General Eric Holder hired to represent the legislature. "Under that framework, the California Legislature, like all State legislatures, is not subject to federal direction or comandeering."

That's for the courts to decide. But this would be the first court challenge in which the administration would be giving a full-throated defense of its deportation requests in court. “It's a whole new ball game with a new administration that wants to go to the mat on this,” Vaughan said.

Speaking of going to the mat ...

Step 4: Trump does it himself

Federal police conduct an immigration raid in Los Angeles in February. (Charles Reed/U.S. Immigration and Customs Enforcement via AP)

Well, not himself himself. But Trump could just order federal deportation officials into California to try to round up undocumented immigrants that California refused to hand over.

But here we get into a problem of resources for the Trump administration, Somin says: Trying to round up immigrants in one sanctuary jurisdiction is like playing whack-a-mole with the others; he'd be taking federal officials away from the dozens of counties that are openly defying the administration.

The final step, perhaps: Congress gets involved

The House chamber (AP Photo/Susan Walsh)

Most of Trump's problems could be solved if Congress passed a law that made it okay for the government to cut off funding for sanctuary cities and states.

Such a law passed the House of Representatives in 2015 and could probably pass the House again if it came up. But it would almost surely face a Democratic filibuster in the Senate — in fact, this kind of law has already been defeated by Senate Democrats.

Even those laws could be subject to court cases challenging the federal government's authority over the states.

Our experts could envision a world where all of this drags out for years and eventually ends up at the U.S. Supreme Court. There's too much at stake politically for both sides to give up easily — for Trump, one of his premiere campaign promises is on the line, and in sanctuary cities, Democrats have a chance to publicly defy Trump and win.

“I don't see any side letting up because it's a political battle, not just a policy one,” Vaughan said. “It's too fundamental to the views of each side.”