Erwin Chemerinsky, Annie Lai and Seth Davis are professors at the University of California at Irvine School of Law.

Cities and public universities are exercising their constitutional authority when they declare themselves “sanctuaries” in response to Donald Trump’s vow to deport 2 million to 3 million immigrants upon taking office next month. Trump has threatened to force state and local governments to implement his deportation policies, including by taking away federal funds, but such actions would be unconstitutional and likely halted by the courts.

The term “sanctuary,” as used in this context, does not mean that a city or institution will conceal or shelter undocumented immigrants from detection. Rather, sanctuary policies might, among other things, commit a city to serving all individuals without regard to immigration status, protect the privacy of community members by keeping their immigration status confidential, or direct law enforcement officers not to investigate, arrest or hold people solely on the basis of immigration status.

Sanctuary policies are an exercise of basic state and local powers to regulate for the health, safety and welfare of their residents. Some entities have acted out of a moral objection to mass deportations, but that is rarely the only motivation. Many local leaders recognize that sanctuary policies are vital to preserving police-community relations and ensuring that residents feel safe reporting crimes and accessing basic government services. Still others are responding to the risk that collaboration with federal immigration officials could lead to racial profiling and civil liberties violations. Public schools and universities have voiced concern that more aggressive immigration enforcement will jeopardize student safety and interfere with their schools’ educational missions.

Trump insists that he can force states and cities to participate in his plan to deport undocumented immigrants. But this ignores the 10th Amendment, which the Supreme Court has repeatedly interpreted to prevent the federal government from “commandeering” state and local governments by requiring them to enforce federal mandates.

For example, in Printz v. United States, in 1997, the Supreme Court struck down a provision of the federal Brady Handgun Violence Prevention Act that sought to require local officers to help enforce federal gun-control laws, including by conducting background checks. In an opinion by Justice Antonin Scalia, the court held that the act violated principles of federalism and the 10th Amendment for Congress by compelling state and local governments to comply with a federal mandate. Under the anti-commandeering principle, the federal government can no more require state and local governments to help it carry out mass deportations than it can require local officers to investigate and enforce federal gun laws.

Some have suggested that there is an exception to the anti-commandeering principle that allows the federal government to demand that states and cities turn over confidential information about undocumented immigrants. But this assertion misreads Supreme Court precedents. The court has held that Congress can require states and cities to disclose information where a statute also requires private parties to turn over the same kind of information. The court has never held that Congress can single out states and cities to share information with the federal government. That is the type of commandeering that the court repeatedly has found violates the 10th Amendment.

Nor can the federal government do indirectly — by threatening to withdraw federal funding from states — what it cannot do directly. In National Federation of Independent Business v. Sebelius, in 2012, the Supreme Court struck down a provision of the Affordable Care Act that required states to expand their Medicaid programs or lose the state’s federal Medicaid money. The court found the condition that Congress placed on states’ Medicaid funding unduly coercive and thus a violation of the 10th Amendment.

There are other limits on Congress’s ability to impose funding conditions on states and localities. Congress must give clear, advanced notice to states of the terms of federal grants, and any conditions imposed on a grant must be reasonably related to the federal interest animating the grant program. Congress likely could not, for example, condition the receipt of a grant for economic development on cooperation with immigration enforcement. Also, funding conditions cannot themselves be used to induce states to violate the Constitution, for example by unlawfully detaining people on immigration detainers without a judicial determination of probable cause.

California Senate President Kevin de León (D) on Dec. 7 unveiled a bill in the state legislature that, if passed, would further remove state and local governments from the business of immigration enforcement. For decades, conservatives have championed states’ rights. The principles they have created mean that states and cities can decline to participate in Trump’s deportation plan, no matter how much his plan’s success may depend on their cooperation.