Namibia's Supreme Court on Monday overturned a decision by a lower court to grant citizenship to a gay couple's son who was born in neighbouring South Africa through surrogacy.
In 2021 the High Court had granted the child citizenship after the interior ministry had denied it on technical grounds.
The government then appealed, saying the couple had failed to comply with the law by registering the birth with the Namibian authorities within one year, as legally required.
The paramount court agreed, saying on Monday that the High Court had "misdirected itself".
"Since the birth... was not registered in terms of... the Citizenship Act, it was not competent for the High court to grant the relief it did to the respondent," it said.
"Because there was non-compliance with... the Citizenship Act, the minister was correct in not granting the minor child citizenship by descent," the court said.
The child, Yona, now aged four, has a South African birth certificate identifying his parents as Phillip Luehl, a Namibian, and Guillermo Delgado, a Mexican.
In its initial complaint, the interior ministry had demanded a DNA test to prove that one of the boy's parents was a Namibian.
But the couple refused to do the test, and the High Court accepted a birth certificate issued in South Africa.
The couple said they were disappointed by the latest ruling but vowed to continue fighting for their son's right to citizenship.
Luehl told journalists that the ruling was just another way of "frustrating people that don't have full access to equality, frustrating them with bureaucratic procedural matters".
"It's very unfortunate," he said.
In an earlier statement, the couple said: "This court is supposed to be the upper guardian of children, supposed to decide in the best interest of children, and here they are giving us the run around."
South Africa, under its liberal post-apartheid constitution, is the sole African nation which allows gay marriage, legalised in 2006.
In Namibia, homosexuality is illegal under a 1927 sodomy law dating back to when the country was under South African rule. The law is rarely enforced.
Uganda: Museveni in State of Nation address reaffirms support for anti-LGBTQ law
Tunisian judges denounce "stranglehold" on the judiciary
Uganda's new gay law draws mixed reactions
Released on bail, Nigeria’s Kuti to begin concert tour amid assault trial
Ugandan LGBTQ activist plans to return home, despite fear of arrest
Go to video
Kenya: LGBTQ+ refugees face serious human rights violations, says Amnesty