South Korea's constitutional court has upheld a law banning same-sex relations in the military, in what activists have called a setback for LGBT rights.
The court said same-sex relationships could harm troops' combat-readiness and undermine discipline.
Same-sex intercourse between civilians however, is not a crime.
Military service is compulsory in South Korea, with all able-bodied men aged between 18 and 28 are required to serve for about 20 months.
Activists condemned the ruling, saying it fuels violence and discrimination against gay soldiers.
The ban has "institutionalized discrimination, reinforced systematic disadvantages faced by LGBT people and risked inciting or justifying violence against them, both inside the military and in everyday life", Amnesty International East Asia researcher Boram Jang said in a statement.
The court, in a five-to-four vote, ruled that article 92-6 of the military criminal act was constitutional. The act does not explicitly refer to same-sex intercourse but bans "anal intercourse" or "any other indecent act" during service.
It was the fourth time since 2002 that the court upheld the law, which carries a prison term of up to two years.
"The world has advanced toward the elimination of LGBT discrimination, but the minds of Constitutional Judges have not taken a single step forward," said Centre for Military Human Rights Korea head Lim Tae-hoon in a statement.
Homosexuality may not be illegal in South Korea - since 2003 it is no longer classified as "harmful and obscene" - but discrimination remains widespread.
Same-sex marriage is not recognised and being gay is sometimes seen as a disability or even a medical condition in South Korea.