Germany introduced "registered partnerships" for same-sex couples in 2001 but stopped short of granting them the full rights and privileges afforded to married couples.
The plaintiff had married a Spanish man in Canada in 2006 but when he returned to Germany, he was registered as single because the authorities did not recognise the foreign wedding.
Now the local registry office must at least list him as half of a "registered partnership", the Berlin administrative court found.
"The court agreed with the view of the authorities that he could not be registered as 'married' because a marriage under German law requires different-sex couples," it said in a statement.
"However the plaintiff could demand registry as a life partner because Canadian gay marriage largely corresponds under German law to a registered partnership."
The court said the policy would apply to any gay couple lawfully married abroad.
Germany's "registered partnership" law grants couples similar privileges to those of married spouses in areas including hospital visits, inheritance and adoption of children but stops short of equality, notably with tax benefits.