The Supreme Court on Monday struck down part of an unusual law that treats fathers and mothers differently when it comes to conferring citizenship on children born outside the U.S.

The 8-0 ruling affects a law that applies to children born abroad to one parent who is an American and one who isn't. The law made it tougher for children of unwed American fathers to gain citizenship themselves.

Justice Ruth Bader Ginsburg said the gender line Congress drew "is incompatible with the Constitution's guarantee of the equal protection of the laws to all persons."

She said the law was based on flawed assumptions that unwed mothers are the sole guardians of children born outside marriage and stereotypes that most men care little about children born out of wedlock.

The case involves Luis Ramon Morales-Santana, a New York resident born in the Dominican Republic to an unwed U.S. citizen father and a Dominican mother. He challenged the law and asserted he is a U.S. citizen after authorities sought to deport him following convictions for robbery and attempted murder.

Under the law, a child born outside the United States to an unwed citizen father and a non-citizen mother can become a U.S. citizen at birth if the father lived in the U.S. for five years, with at least two of those years coming after the age of 14.

But an American mother must only have lived in the U.S. continuously for one year before giving birth to a child to meet the requirement.

A federal appeals court struck down the law and said the one-year period must apply to both unwed fathers and mothers. The Obama administration appealed.

While the court struck down the gender differences in the law, Ginsburg said the longer five-year period should apply to both mothers and fathers until Congress decides on a different length of time. That means Morales-Santana is still unable to win his citizenship case.

The government had urged the justices to uphold the law's gender-based differences. The Justice Department said Congress wanted to make sure there is a strong connection between a child born overseas and the United States before granting citizenship. The law also considered the practices of other countries.