The woman in her 30s, known in the Court of Final Appeal as "W" under anonymity rules, successfully overturned earlier verdicts that said marriage is only allowed between couples who were of the opposite sex at birth.
W, who underwent sex realignment surgery more than five years ago, argued that her post-operative gender is recognised by the law and that previous rulings were a violation of her constitutional rights.
She also said that her re-assignment surgery had been government-subsidised.
The city's Registrar of Marriages had argued that she could not wed her boyfriend because her birth certificate -- which cannot be altered under Hong Kong law -- said she was male.
"It is contrary to principle to focus merely on biological features fixed at the time of birth," the court said in a written judgement by the panel of five judges.
It added that existing laws "impair the very essence of W's right to marry".
The court said the nature of marriage as a social institution had "undergone far-reaching changes" in a multi-cultural present-day Hong Kong.
"The effect of this decision is that W will be allowed to marry, and should be allowed to marry her boyfriend," lawyer for W, Michael Vidler, told reporters outside the courthouse after the ruling was announced.
"This is a case about sexual minorities being recognised and that their rights are just as important as everyone else's," Vidler said of what he called a "landmark decision".
W, who was not in court Monday, said in a statement read by Vidler: "I have lived my life as a woman and treated as a woman in all respects except as regards to my right to marry. This decision rights that wrong."
"I am very happy that the court of appeal now recognises my desire to marry my boyfriend one day and that that desire is no different to that of any other women who seek the same here in Hong Kong."
"This is a victory for all women in Hong Kong."
The court will suspend the decision for 12 months allowing time for the government to amend the city's marriage laws.
In rejecting W's case in 2010, a lower court said there was insufficient evidence "to demonstrate a shifted societal consensus in present-day Hong Kong regarding marriage to encompass a post-operative transsexual".
W's lawyers had previously argued that many countries have allowed transsexual people to marry the opposite sex in their new gender, including mainland China since 2004, as well as Japan and Australia.