SEOUL, South Korea — The army lieutenant knew his career was irrevocably damaged when military investigators visited him in 2017, demanding that he admit having had sex with another male soldier — a crime in South Korea’s military.

When the investigators put him on a video call with his ex-lover, who admitted to the relationship, he felt he had to confess. Then they seized the lieutenant’s smartphone, pressing him to identify gay soldiers in his contact lists. And they humiliated him with questions like “What sex positions did you use?” and “Where did you ejaculate?”

The lieutenant — who in an interview asked to be identified only by his surname, Kim — could have gone to prison, but his indictment was suspended because of his “contrition.” He chose to leave the army, though, believing that he no longer had a future there.

South Korea’s military says it does not discriminate against sexual minorities. But Mr. Kim is one of an increasing number of gay or transgender soldiers who have been persecuted under Article 92-6 of the Army Criminal Act, which has been used to out them and punish them for consensual sex, Amnesty International said in a report released on Thursday.