A federal judge has blocked key parts of Arizona's strict immigration law, hours before it takes effect.
The judge issued a temporary injunction against a requirement that police check the immigration status of criminal suspects they had stopped while enforcing other laws.
Also blocked was a section making it a crime not to carry immigration papers.
Among the provisions kept was one making it illegal to transport and harbour illegal immigrants.
Also allowed to stand was a section of the law making it illegal for drivers to pick up day labourers from the street.
US District Judge Susan Bolton said the blocked sections pre-empted the federal government's authority to set immigration law.
The Republican-controlled Arizona legislature passed the law in April, amid fears of rising crime caused by illegal aliens and complaints the federal government had failed to act on the matter.
Among the controversial sections blocked by the judge was one making it a crime for undocumented workers to seek or apply for a job and another allowing police to arrest without a warrant people whom they had probable cause to believe had committed a crime for which they could be deported.
The United States was likely to "suffer irreparable harm" if she did not block enforcement of those sections, she wrote.
"Requiring Arizona law enforcement officials and agencies to determine the immigration status of every person who is arrested burdens lawfully present aliens because their liberty will be restricted while their status is checked," she wrote.
She also wrote that the surge in requests for immigration status checks would force the federal government to shift resources away from its own priorities.
The judge also agreed with an argument by the administration of President Barack Obama that "the federal government has long rejected a system by which aliens' papers are routinely demanded and checked".
She let other parts of the law stand, including one barring Arizona counties and towns from restricting enforcement of federal immigration laws.
Arizona Governor Jan Brewer, a Republican who strongly supported the law, pledged to appeal against the ruling.
"We will take a close look at every single element Judge [Susan] Bolton removed from the law, and we will soon file an expedited appeal at the United States Court of Appeals for the 9th Circuit," Ms Brewer said in a statement.
"It's a temporary bump in the road, we will move forward," she told the Associated Press news agency. "The bottom line is we've known all along that it is the responsibility of the [federal government], and they haven't done their job, so we were going to help them do that."
The US justice department hailed the ruling, while acknowledging "the frustration of Arizonans with the broken immigration system".
"A patchwork of state and local policies would seriously disrupt federal immigration enforcement and would ultimately be counterproductive," spokeswoman Hannah August said in a statement.
"We will continue to work toward smarter and more effective enforcement of our laws while pressing for a comprehensive approach that provides true security and strengthens accountability and responsibility in our immigration system at the national level."
The Mexican government, which has repeatedly expressed concerns about the Arizona law, called the ruling a "first step in the right direction".
The injunction is a temporary measure until the judge can decide on the law's constitutionality.
The law was scheduled to take effect on Thursday, and the state was expecting a surge of protesters rallying against it.