An Arizona judge has heard federal government arguments aimed at halting a law targeting illegal immigrants.
The justice department says immigration is a federal issue, and that Arizona has exceeded its powers in framing the law, to be implemented next week.
The rules require police to query a suspected criminal's immigration status if the officers believe the suspect might be in the US illegally.
Judge Susan Bolton has not yet issued a ruling, which could come any time.
She grilled lawyers during the 90-minute hearing on whether Arizona's law would lead to racial profiling and whether it infringed upon federal authority over immigration.
Judge Bolton asked Justice Department attorney Edwin Kneedler to explain the government's case.
"Why can't Arizona be as inhospitable as they wish to people who have entered the United States illegally?" she asked him.
She also questioned the lawyer for the state of Arizona about the impact the law might have on US foreign policy.
"It seems to have gotten some people from foreign countries upset with us," the judge said.
Among those objecting to the law are civil liberties groups, an Arizona police officer and the governments of Argentina, Ecuador and Mexico.
Opinion polls suggest the law has widespread support among the public, and Arizona's state legislature says it has been forced to act because the federal government failed to do so.
The state, which borders Mexico, is the biggest entry point into the US for illegal immigrants, and is home to an estimated 460,000 illegal immigrants.
Arizona Governor Jan Brewer signed the measure into law in April and it is due to come into effect on 29 July.
Her lawyers want the Phoenix court to dismiss the federal government's case; the government wants the judge to halt the implementation of the law while its case in considered.
Analysts warn that the case - along with several other lawsuits challenging the legislation - could take years to resolve.
The court has not yet indicated whether there will be any ruling to postpone the law's implementation while legal action is handled.
The legislation was passed after years of frustration in the state about problems associated with illegal immigration, including drug-trafficking and violent kidnappings.
The rules require state and local officers - who are not federal agents - to question the immigration status of people stopped for a legitimate reason who arouse suspicion of being in the US illegally.
The law also requires foreign nationals to carry immigration documentation, even if they are legal residents.
Its critics say the rules are unfair to legal immigrants and will lead to racial profiling of suspects.