The Supreme Court ruled in favor of a Mexican immigrant who faced deportation after he was convicted of having consensual sex with his underage girlfriend. The justices handed down a unanimous decision on Tuesday that, while Juan Esquivel-Quintana committed a crime under California law, his conduct does not violate federal immigration law.

California law outlaws sex with anyone under age 18 if the age difference is more than three years. That applied to Esquivel-Quintana, who had sex with his 16-year-old girlfriend before and after his 21st birthday.

Esquivel-Quintana argued his conduct would have been legal under federal law and the laws of 43 other states that are less strict.

The government argued that courts should defer to immigration officials in interpreting laws that are vague.