Bangkok's Juvenile and Family Court ruled on Tuesday that US citizen Gordon Lake (pictured above, left) was Carmen's legal guardian, his lawyer, Rachapol Sirikulchit, told reporters.

"The court has granted legal custody of Carmen Lake to Gordon Lake, my client, and my client is her only guardian," the attorney said.

Lake's partner, Spaniard Manuel Santos (pictured above, right), was elated at the verdict. "We won," he told journalists, adding, "We are really happy… This nightmare is going to end soon."

Santos and Lake had been stuck in Thailand since January 2015, when Carmen was born. The two have been living off of finances from a crowdfunding website where they had appealed for help.

Lake is Carmen's biological father, while the egg came from an anonymous donor. After Carmen's birth, her surrogate mother Patidta Kusolsang gave the baby to Lake and Santos.

Manuel Santos and his partner have been stuck in Thailand for nearly 15 months

Although Carmen had been living with the couple since her birth, her surrogate mother changed her mind and did not sign the documents to enable Carmen to obtain a passport. The two men were told that Patidta did not know they were gay before handing over the child.

Lake's same-sex marriage with Santos became a problem in Thailand, which does not recognize homosexual unions. However, the 41-year-old American insisted the matter had been clear ever since they tied up with surrogacy agency New Life, which has branches in several countries.

This was further complicated by a ban on surrogacy in 2015 following a series of scandals involving foreign adoptions. However, the ban took effect only after Carmen was born.

In one high-profile case, an Australian couple was accused of abandoning a baby with Down's Syndrome, while taking away her twin back home with them. In another scandal, a Japanese man had 15 babies with surrogate mothers.

mg/kms (AFP, AP)