Many commentators have sought to draw an equivalence between Rowan County, Kentucky clerk Kim Davis’s refusal to issue same-sex marriage licenses, in defiance of a federal court order, and the decision of so-called “sanctuary cities” to refuse to enforce federal immigration laws. Yet as a legal matter, the questions presented by the two scenarios are quite distinct. Put directly, Kim Davis is acting in defiance of applicable federal law; sanctuary cities are not — and we can again cite Justice Scalia to explain the difference.

So-called sanctuary cities are jurisdictions in which local officials have decided that they will not cooperate with federal immigration enforcement. Put another way, they are jurisdictions in which local officials are refusing to implement a federal program. The decision to become a sanctuary city may be regrettable, unwise, or worse, but it is perfectly legal and entirely consistent with our constitutional structure.

The Constitution establishes that federal law is supreme. But it is also well-established that the federal government may not “commandeer” state and local governments to implement federal law. What this means is that the federal government is free to enforce federal law, including immigration law, whether state or local officials like it or not. At the same time the federal government cannot dictate that state and local officials enforce that law on the federal government’s behalf.

One of the cases establishing this principle is Printz v. United States, in which the Supreme Court held that state and local law enforcement officials are not obligated to perform federally mandated background checks before individuals could purchase guns. The federal government could impose such a requirement if it wished, the Court held, but it could not force state and local officials to do the dirty work. If the federal government wanted state and local law enforcement to implement such a federal law, it would have to make it worth their while, such as by providing financial inducements or some other incentive. As the Printz opinion concluded:

The Federal Government may neither issue directives requiring the States to address particular problems, nor command the States’ officers, or those of their political subdivisions, to administer or enforce a federal regulatory program. It matters not whether policymaking is involved, and no case by case weighing of the burdens or benefits is necessary; such commands are fundamentally incompatible with our constitutional system of dual sovereignty.

And who wrote the Supreme Court’s Printz decision? None other than Justice Scalia.

Local jurisdictions that elect to become “sanctuary cities” are taking the same legal step as the state and local law enforcement officers who refused to perform background checks for gun purchases. They are saying to the federal government, in effect, if you like this federal law so much, you enforce it yourself. Whatever one thinks of the policy merits in either case, they are legally the same.

County clerks like Kim Davis, on the other hand, are not being asked to administer or implement a federal program. To the contrary, issuing marriage licenses is a function of state and local government governed by state law. Rather, Davis and other county clerks are being ordered to administer their own state and local programs in conformance with the Constitution, as interpreted by federal courts, and the Supremacy Clause provides that state laws must yield when they conflict with federal law.

Davis and others may feel that Obergefell was wrongly decided. For the sake of argument, let’s assume she is correct. (As they say, the Supreme Court is not final because it’s always right; it’s right because it’s final.) Davis may have been within her rights to refuse to issue same-sex marriage licenses until she became subject to a lower court order directing her to do so. Now that she is subject to such an order, however, she has an obligation to comply, or face potentially significant sanction. Local officials who create sanctuary cities, on the other hand, face no such legal jeopardy, because they are under no obligation to implement or enforce federal law. And that is how our system works.