Arizona’s campaign to implement its own anti-immigration law and enforcement policy—a campaign emulated by several other states—came to a virtual dead end in June, as the Supreme Court ruled that immigration law is the prerogative of Congress and the executive branch, and that states may not adopt laws or enforcement policies that conflict with federal law. Although many people predicted after oral argument that much of Arizona’s law would be upheld, the Court struck down three of the four provisions at issue as inconsistent with federal law. Even regarding the fourth provision, the “show me your papers” rule authorizing Arizona police to check the immigration status of people they have stopped or arrested, the Court said that it was too early to tell whether it was valid or invalid, and that a ruling on its legality would ultimately depend on how it is applied. If, as seems likely, this provision is enforced in a way that invites racial profiling, it may still be invalidated. In short, the decision, written by Justice Anthony Kennedy and joined by Chief Justice John Roberts and Justices Ruth Bader Ginsburg, Stephen Breyer and Sonia Sotomayor, was a victory for the government and a huge loss for anti-immigrant forces. As President Obama, celebrating the decision, said, “I agree with the Court that individuals cannot be detained solely to verify their immigration status. No American should ever live under a cloud of suspicion just because of what they look like.”

In some respects Arizona v. United States should not have come as a huge surprise. The politics of immigration are deeply divided, but conservative and liberal justices have long been united on one thing: immigration law is a federal matter. The immigration power is expressly assigned to Congress by the Constitution, and it obviously implicates basic questions of federal sovereignty and foreign relations. To allow each state to enforce its own immigration law would be a disaster. The Court’s ruling reinforces that principle, holding that states may not interfere with Congress’s power to legislate on immigration, or the executive’s authority to enforce immigration law (as President Obama illustrated the week before the Arizona decision, when he announced that he would exercise his discretion to stop deporting certain young undocumented immigrants).

Two of the four provisions at issue made it a crime under Arizona law to be in the United States in violation of federal immigration law. Arizona argued that since it was only adding state penalties for conduct that federal law had already made illegal, it was acting within its authority. The Court rejected that argument, holding that it is Congress’s decision, not Arizona’s, how to punish violations of immigration law. Arizona made a crime of conduct that Congress chose to treat only as a civil immigration infraction. That, the Court said, is flatly inconsistent with the federal immigration scheme. Under this part of the decision, all copycat state laws that add criminal penalties to federal immigration law will almost certainly be impermissible.

A third provision authorized Arizona police to make warrantless arrests of people they have probable cause to believe were here in violation of federal immigration law. Arizona said it was just “cooperating” with federal authorities by arresting people who appeared to be violating federal law. Again, the Court dismissed that contention, pointing out that Arizona had given its officers greater power to arrest immigrants than Congress had given its own federal officers. Congress has said that state officers may cooperate with the federal government on immigration, the Court noted, but only when invited to do so (and, under current law, only when first trained in the complexities of immigration law). Whatever “cooperation” means, the Court reasoned, it cannot possibly encompass the “unilateral decision of state officers to arrest an alien for being removable absent any request, approval, or other instruction from the Federal Government.”

Some civil rights and immigrants’ rights groups have expressed disappointment that the Court left standing a fourth provision. It requires Arizona officers to check the immigration status of any person they stop or arrest for some other reason when they have “reasonable suspicion” that the person might be here in violation of federal immigration law and bars the release of anyone arrested before his or her status is determined. This provision, critics rightly assert, is bound to invite racial profiling in its enforcement—it seems highly likely that Arizona officers’ “reasonable suspicion” will be based on racial or ethnic appearance (even though in a state like Arizona, with a substantial Latino citizen population, that’s hardly a reasonable basis for suspicion). But as noted—and contrary to some of the civil rights groups’ criticisms—the Court did not uphold this provision.

Here’s what the Court said about the “show me your papers” provision. First, it noted that the law was challenged before it went into effect, and that on its face it includes several important limitations. The law says that showing an Arizona driver’s license or similar identification is presumed to establish legal status, and it prohibits consideration of race or ethnicity except as permitted by the Constitution. And it says it must be implemented consistent with federal law. Moreover, the Court said, there is nothing inherently inconsistent with federal law for a state official who has lawfully stopped someone for some other purpose merely to inquire into his or her status. The decision about what to do with that person would remain a federal matter.

At the same time, the Court warned that “detaining individuals solely to verify their immigration status would raise constitutional concerns,” and that delaying their release to determine status would “disrupt the federal framework.” But as the law was enjoined by the lower federal courts before going into effect, it had not yet been interpreted by the state courts. The state courts, the Supreme Court speculated, might interpret the provision to avoid direct conflict with federal law—by holding, for example, that it requires officers only to institute checks, but not to complete them, before an arrested person is released. And it stressed that once the law goes into effect, “other preemption and constitutional challenges” could be pursued. Thus, if this provision leads to racial profiling, or to detentions that are initiated or extended for status checks, it can be challenged again—and under this opinion, very likely would be invalidated.

In short, the Arizona decision was a near-complete victory for those who have been fighting many states that want to use their laws to make life miserable for immigrants. It concluded with a heartfelt reminder that we are a nation of immigrants, almost as if the Court were pleading with the country for compassion and reason in an area that has been dominated by vitriol and demagogy. We should celebrate Arizona v. United States for the roadblock it has erected to the state anti-immigrant movement. Comprehensive immigration reform remains essential at the federal level, but at least this decision means that efforts to target immigrants at the state level are likely to fail.