Mr. Obama emphasized his concern that the remaining provision could lead to racial profiling, an issue that the court may yet consider in a future case. “No American should ever live under a cloud of suspicion just because of what they look like,” Mr. Obama said in a statement, adding that he was “pleased” about the parts that were struck down.

In her own statement, Gov. Jan Brewer of Arizona, a Republican, said she welcomed the decision to uphold what she called the heart of the law. The decision, she said, was a “victory for the rule of law” and for “the inherent right and responsibility of states to defend their citizens.”

Still, the ruling was a partial rebuke to state officials who had argued that they were entitled to supplement federal efforts to address illegal immigration.

The Obama administration argued that federal immigration law trumped — or pre-empted, in legal jargon — the state’s efforts. Last year, the United States Court of Appeals for the Ninth Circuit, in San Francisco, blocked the four provisions on those grounds, including the one the Supreme Court upheld.

In its challenge, the administration did not argue that it violated equal-protection principles. At the Supreme Court argument in April, Solicitor General Donald B. Verrilli Jr. acknowledged that the federal case was not based on racial or ethnic profiling.

In the majority opinion, Justice Kennedy wrote that the ruling did not foreclose other “constitutional challenges to the law as interpreted and applied after it goes into effect.”

Meanwhile, Attorney General Eric H. Holder Jr. said on Monday that the federal government would “continue to vigorously enforce federal prohibitions against racial and ethnic discrimination.”