WASHINGTON — Unwed mothers and fathers may not be treated differently in determining whether their children may claim American citizenship, the Supreme Court ruled on Monday. “The gender line Congress drew is incompatible with the requirement that the government accord to all persons ‘the equal protection of the laws,’” Justice Ruth Bader Ginsburg wrote for the majority.

The case concerned Luis Ramon Morales-Santana, who was born in 1962 in the Dominican Republic. His father was an American citizen, but his mother was not. His parents were unwed but later married.

The family moved to the United States when Mr. Morales-Santana was 13, and he lived in this country for decades. After convictions for robbery, attempted murder and other crimes, federal authorities sought to deport him.

He resisted, claiming American citizenship. But the law in effect when he was born allowed unwed fathers of children born abroad to transmit citizenship to them only if the fathers had lived in the United States before the child was born for a total of 10 years, five of them after age 14. Mr. Morales-Santana’s father fell just short of satisfying that requirement.