Mexico has waded into a legal challenge to a new immigration law in the US state of Arizona.
In papers submitted to a US federal court, the Mexican government argues that the law is unconstitutional and would damage bilateral relations.
It says it is concerned that it could lead to unlawful discrimination against Mexican citizens.
The law - which comes into force on 29 July - makes it a state crime to be in Arizona without immigration papers.
It also requires police to question people about their immigration status, if officers suspect the person is in the US illegally, and if they have stopped them for a legitimate reason.
The Mexican government submitted arguments as a "friend of the court", or amicus curiae, meaning it is not a party to the case, but is offering a legal opinion which it believes has bearing on it.
It is in support of a case brought by a group of civil rights organisations, including the Mexican American Legal Defense and Education Fund, the National Immigration Law Center, and the American Civil Liberties Union.
It urges the federal court in Arizona to declare the law unconstitutional and stop it coming into effect.
"Mexico has a duty to protect its citizens and ensure that their ethnic origin is not used as a basis for committing discriminatory acts," the Mexican foreign ministry said in a statement.
It said it would respond forcefully to any violation of the fundamental human rights of all Mexicans in Arizona, independent of their immigration status.
The action is one of five separate challenges to the Arizona immigration law.
The measure has widespread support in Arizona, where there is growing concern at the flow of illegal migrants across the border from Mexico.
Arizona governor Jan Brewer has said she was forced to act because the federal government had failed to tackle illegal immigration.
Other states are considering similar moves.
President Barack Obama has called the law misguided.
He has made immigration reform a priority, amid pressure from US border states for action to help curb illegal immigration and drug violence.
Last month, he said he would seek more funding and deploy up to 1,200 extra troops to help secure the US-Mexico border.