South Korea’s constitutional court on Thursday narrowly upheld a law banning same-sex relations within the armed forces, citing a possible risk to the military’s combat readiness in a ruling criticised by activists as a setback for gay rights.

Under the country’s military criminal act, members of the armed forces face up to two years in prison for same-sex relationships. The law has been referred to the court and upheld by it four times since 2002.

In Thursday’s five-to-four ruling, the court said allowing same-sex relations could undermine discipline within the military and harm its combat capabilities.