South Korea’s Supreme Court overturned the convictions of two soldiers who had been charged with having consensual sex while off their base.

The landmark ruling, which was issued on 21 April, stated that the country’s decades-old ban on homosexual activities should not apply to gay sex outside of a military setting.

The Military Criminal Act states that those engaging in “anal intercourse or other indecent acts” should face up to two years in prison, which has previously been used to punish military personnel engaging in consensual gay sex.

The two defendants, a first lieutenant and a master sergeant from different units, were found to have had sex in a private house in 2016 at a time when they were not working.

The lieutenant was sentenced to four months behind bars, with the sergeant facing three – though these sentences were suspended when the men appealed the decision.

The Supreme Court has now struck down the men’s charges of breaking the military code.

Punishing them was a violation of “their sexual autonomy” and “the constitutionally guaranteed right to equality and human dignity, as well as their right to pursue happiness,” the court ruled.

“The specific ideas of what constitutes as indecency has changed accordingly with the changes in time and society,” Chief Justice Kim Myeong-su said during the decision, according to the Associated Press.

“The view that sexual activity between people of the same sex is a source of sexual humiliation and disgust for objective regular people and goes against decent moral sense can hardly be accepted as a universal and proper moral standard for our times.”

The case has now been sent back to a lower military court for review.

“This groundbreaking decision is an important triumph in the fight against discrimination faced by L.G.B.T.I. people in South Korea,” Boram Jang, Amnesty International’s East Asia researcher, told The New York Times.

“The criminalization of consensual same-sex sexual acts in South Korea’s military has long been a shocking violation of human rights, but today’s ruling should pave the way for military personnel to freely live their lives without the threat of prosecution.”

The law in question has been widely condemned by LGBTQ+ activists who have said it unfairly targets gay soldiers.