A transgender woman has been granted sanctuary in the UK to protect her from doing compulsory military service as a man in Singapore.

In the first case of its kind, two judges ruled that she should not be forcibly returned to her home country, where she would be forced to do two weeks of military service a year for the next eight years.

The Home Office argued that she should be sent back to Singapore, claiming any discrimination against her would not amount to serious harm.

The 33-year-old, who cannot be named for legal reasons, came to the UK as a student in September 2004. The Home Office has accepted that she is a woman and the gender on her Home Office ID card is female.

She completed military service as a man in Singapore between December 2001 and June 2004 and has said she felt uncomfortable when serving with men.

Women in Singapore, including transgender women who have undergone reassignment surgery, are not expected to participate in military service. The student has been living as a woman for the past 10 years but has decided against having the full gender reassignment procedure and would therefore face calls to serve.

If she was sent back to Singapore she would have to do two weeks a year of military service until 2023. If she refused she could face 15 months in prison and a fine of $10,000 (£7,000).

She said that having lived as a woman for a decade she would find it intolerable to be treated as a man and has recurrent nightmares about her previous military service.

The case was heard in the first tier of the immigration tribunal by Judge Jackson last November. “I find that the requirement of the appellant to essentially hide her gender and live as a man, even for two weeks a year, would be wholly unreasonable,” Jackson said.

She added that it would be a fundamental breach of her right to a private life and expression of her gender identity.

Her barrister, S Chelvan of No 5 Chambers, argued that if the Home Office returned her to Singapore it would be returning a woman to her home country to be punished as a man.

The Home Office appealed against the judgment but this week a second judge, Judge Harris, rejected the appeal and also found in the woman’s favour.

Earlier this month the all-party parliamentary group on global lesbian, gay, bisexual and transgender rights (LGBT) said the Home Office needed to improve decision making on LGBT cases and review its policy guidance on gender identity claims.

Last month the US state of North Carolina passed the controversial “bathroom law”, requiring transgender people to use the toilet relating to the gender of their birth rather than the gender they identify with. Bruce Springsteen cancelled a concert there in protest against the new law.

The woman’s solicitors, West 12, said: “We are pleased that the plight of this transgender woman has been resolved successfully. It means she can now enjoy living a full life without any compromise to her gender identity or her personal integrity. This is a basic right denied to her in Singapore.”