A US appeals court has granted a transgender illegal immigrant the right to stay, as she would face discrimination in Mexico.
The court ruled that Edin Carey Avendano-Hernandez was protected under international anti-torture conventions.
The judges said Mexico suffered from "an epidemic of unsolved violent crimes against transgender persons".
They said US immigration officials who wanted to deport her had mixed sexual orientation with gender identity.
Writing in the ruling for the 9th Circuit panel, Judge Jacqueline Nguyen said: "Country conditions evidence shows that police specifically target the transgender community for extortion and sexual favours and that Mexico suffers from an epidemic of unsolved violent crimes against transgender persons.
"Avendano-Hernandez, who takes female hormones and dresses as a woman, is therefore a conspicuous target for harassment and abuse."
Ms Avendano-Hernandez was born male and grew up in Oaxaca, Mexico.
After seeking refuge in the US, Ms Avendano-Hernandez was convicted twice of driving under the influence in 2006.
She was thus ordered deported by immigration officials.
Ms Avendano-Hernandez suffered further abuse on her return to Mexico and went back to the US, where she was later arrested for probation violation.
Facing deportation again, she applied for refuge under the United Nations Convention Against Torture.
After the latest ruling, her lawyer, Munmeeth Soni, told Associated Press: "She's ecstatic. The fear was constantly hanging over her head that she might have to one day turn herself in to return to Mexico.
"She no longer lives under that fear."