Aiden and Ethan Dvash-Banks are twin brothers who were born minutes apart.

But only one of them was considered to be a United States citizen by the State Department. A federal judge ruled this week that was a mistake.

The twins are the sons of two married gay men, an American citizen and an Israeli citizen. Aiden was conceived using sperm from his American father and Ethan was conceived using sperm from his Israeli father, court records show. A surrogate mother gave birth to the boys in Canada in 2016.

The family sued the State Department for denying Ethan citizenship, drawing attention to a department policy that says that a child born abroad must be biologically related to an American parent to become a citizen. Gay rights activists argued that the policy harms same-sex couples, who often use assisted reproductive technology to have children.

“Two kids who have almost identical life experiences and parenting,” said Aaron C. Morris, a lawyer for the family and the executive director of Immigration Equality, a legal advocacy group that worked on the case. “To treat them differently is absurd.”