The man had conceived the child through a surrogate in the United States.

A gay man in Singapore can now legally adopt the child he conceived through in vitro fertilization thanks to a landmark ruling.

The conservative Asian city-state’s High Court overturned a previous decision that denied a 46-year-old doctor, who is not identified by name, the right to adopt his son, now 5, CNN reports.

Previously, the man had paid $200,000 for surrogacy services — which are illegal in Singapore — for the conception of a child in the United States.

His son was born 2013 in Pennsylvania, after the father’s sperm fertilized an egg from an anonymous egg donor. After the surrogate mother, an American citizen, gave up parental rights, the father returned with the child to Singapore.

In Singapore, children born outside of a marriage are deemed illegitimate and must be adopted in order to obtain full citizenship. Same-sex marriage is not legal in the city-state and neither is sex between men, which can result in a two-year prison sentence.

The man, who has a long-term partner of 13 years, will be considered the child’s sole parent after the adoption, since the pair will be unable to file as a married couple. Legally, only different-sex couples can adopt a child.

Chief Justice Sundaresh Menon stressed in the court’s decision, issued Monday, that the ruling "should not be taken as an endorsement" of same-sex households nor a judgment of what "a family unit ought to be.”

However, “the evidence has demonstrated to us that it is very much in the interests of the Child that the adoption order be made, having regard principally to the fact that his prospects of acquiring Singapore citizenship could be significantly enhanced."

The man called the court process "a long and difficult journey for our family" in a statement to CNN, but added, "we are happy and relieved with the High Court's ruling."

"We hope that with the adoption order, it will increase the chances of our son residing in Singapore for the long term. Singapore is the only place we have known as home, and is where we wish to raise our family,” he stated.

Singapore's ban on gay sex is a holdover from colonial-era laws; the city-state was under British rule until 1963. The recent landmark decision by the Indian Supreme Court to overthrow its 157-year-old sodomy laws, however, has encouraged LGBTQ activists in Singapore to protest their country's antigay laws.