The US Supreme Court has upheld a key part of a tough Arizona immigration law that would give new powers to police to check the immigration status of people stopped and arrested.
However, three of four challenges brought by the Obama administration were upheld by the court.
The US government had argued the law infringed on federal rights to oversee immigration policy.
Five other states have adopted variations of the Arizona law.
A provision known as Section 2(B), that requires police to make a "reasonable attempt... to determine the immigration status" of anyone who is stopped for another violation, was upheld by the Supreme Court.
The court ruled it was too early to tell whether the clause caused a conflict with federal laws, but added that the provision could be open to legal challenge again at a later date.
The Supreme Court also struck down three other parts of the law.
One clause would require immigrants to carry proof of their status with them, and another would have made it a crime for undocumented workers to apply for a job.
The court also struck down a provision that would have allowed police to stop people purely on the suspicion that they were in the country illegally.
Justice Anthony Kennedy, who wrote the opinion for the court, said the justices were unanimous in their decision to allow the "check your papers" provision to come into effect. The court was divided on other issues.
One Supreme Court Justice, Antonin Scalia, dissented from the case, saying he would uphold all parts of the Arizona law, citing the sovereignty of individual states as defined in the US constitution.
Arizona’s Republican governor, Jan Brewer, called the court’s ruling a victory, saying the "heart" of the bill could now come into effect.
In a statement, Ms Brewer said the ruling was a victory for "all Americans who believe in the inherent right and responsibility of states to defend their citizens.
But she warned against misuse of the provision, adding: "Law enforcement will be held accountable should this statute be misused in a fashion that violates an individual’s civil rights."
Other reaction to the law was nuanced, and at least partly open to interpretation: some claimed victory for backers of the law, while others saw the ruling as a partial victory for the administration.
Immigration has become a key issue as the US edges closer to this year’s presidential election.
President Barack Obama recently outlined a plan to allow hundreds of thousands of illegal immigrants who came to the US as children the option of legal status and work permits.
His Republican rival Mitt Romney has opposed Mr Obama’s plan, but has not said how he would address the issue of immigration.
Both men are courting Hispanic votes ahead of their showdown in November.