THE SUPREME COURT didn’t gut Arizona’s over-the-top immigration law, but it came close.

The five justices in the majority made clear that Arizona blatantly overreached by trying to take enforcement of federal immigration law into its hands — making it a state crime, for instance, for illegal immigrants to hold a job or to apply for one, or to be present in the state without valid papers. In so doing, the court served notice to other states that immigration policy remains primarily Washington’s domain. It also dealt a blow to those, such as Mitt Romney, who have embraced the idea that illegal immigrants will “self-deport” if laws are made sufficiently onerous.

Nonetheless, the court (with Justice Elena Kagan not voting) upheld the law’s most obnoxious feature: its “show me your papers” section, which requires law officers to check the immigration status of anyone stopped or arrested for any reason, based on an ill-defined “reasonable suspicion” that they are undocumented. Whether that provision survives ongoing litigation in the state courts is an open question; it may contain the seeds of its own destruction.

With good reason, the Supreme Court said that “detaining individuals solely to verify their immigration status would raise constitutional concerns.” State police, the justices said, have no business jailing illegal immigrants simply for being unlawfully present in the country, without authorization from federal authorities.

The justices expressed some faith that state courts would deem it unreasonable for authorities to hold a jaywalker for a lengthy detention while trying to verify his immigration status. But there is ample reason to believe that such practices are common in parts of Arizona and may become more so now that the law’s “show me your papers” section has the court’s provisional approval.

In sprawling Maricopa County, for example, which includes Phoenix, the overzealous sheriff’s office is notorious for detaining and arresting people on such pretexts as broken taillights and minor moving violations, and the presumption of illegal-immigration status is often arrived at by little more than a quick once-over. If law enforcement officers routinely use such pretexts to carry out what amount to sweeps of undocumented immigrants, what remains of Arizona’s immigration law may not survive future legal challenges. As the justices said, their ruling Monday doesn’t close the door on further litigation once the law takes effect.

In the meantime, the court’s ruling may mark a milestone in the American debate over the dysfunctional immigration system. After an initial flurry of Republican-sponsored copycat legislation inspired by the Arizona law, states seem to have lost some of their zeal for hounding and harassing the country’s 11 million undocumented immigrants. Now the justices have held up a cautionary hand, warning state lawmakers against further poaching on the federal government’s turf.