SEOUL, South Korea — The Constitutional Court in South Korea on Thursday rejected a challenge to the country’s ban on the sex trade, handing a defeat to prostitutes who have campaigned for years to decriminalize their work.

“The growing trend to liberalize and promote openness in sex doesn’t condone or justify its commercialization,” Justice Kim Chang-jong wrote in the court’s majority ruling, which found that the 2004 antiprostitution law, under which prostitutes and their clients can be fined and imprisoned for up to a year, did not violate the South Korean Constitution. Justice Kim’s opinion was endorsed by five other justices.

But the court was more divided than in past rulings upholding the ban. Three of its nine justices fiercely criticized what they called a government crackdown on women driven to prostitution by desperate circumstances. One dissenting justice, Cho Yong-ho, called the choice of those women “a matter of survival.”

“The majority view insists that prostitution should not be protected by law because it harms human dignity,” Justice Cho wrote in his dissent. “But nothing harms human dignity more than a threat to survival.”