BANGKOK, Thailand — There’s some good news for transgender Muslim women in Malaysia. An influential court ruling says cops can’t persecute them under religious law just for wearing dresses and lipstick.

Keeping the police away, however, may require a demeaning concession: getting certified as mentally ill.

Malaysia is a bastion of conservative Islam, a tropical Southeast Asian nation where Muslim scholars warn against the wicked effects of Valentine’s Day and yoga.

Homosexuality isn’t just taboo in Malaysia. It’s punishable by $300 fines, jail time or even public whippings. Muslims, who constitute two-thirds of the nation, are bound by a system of Sharia law. Those codes, derived from the Quran, explicitly forbid men from dressing as women.

But in a break from their typically conservative bent, judges ruled in November that arresting lifelong “cross dressers” is “degrading, oppressive and inhuman.” Their reason: The so-called cross-dressers suffer from a mental illness called “gender identity disorder.”

The judges may be out of synch with 21st-century Western thought, which increasingly views transgender discrimination as a new civil rights frontier. But this ruling is actually quite forward-thinking in Malaysia, where orthodox Muslims have great sway.

“This is a courageous decision by the court,” says Syahredzan Johan, an attorney who provided a legal opinion to judges during their deliberation. “It will hopefully spark scrutiny on Sharia amendments throughout the country.”

He suspects it will also spark backlash from conservatives warning about homosexual tolerance, as they see it, tainting Malaysia’s piety. “They tend to say, ‘Look, this shows the enemy’s at the gates and liberalism is threatening the fabric of our society,’” Johan says.

The ruling came about after three transgender women — Muslim men in the government’s eyes — grew fed up with frequent arrests by police citing Islamic law. A court brief acquired by GlobalPost indicates the trio willingly submitted to a battery of tests from psychiatrists to prove their “gender identity disorder.”

The doctors’ findings: “cross dressing is intrinsic to the appellants’ nature” and “this abnormal condition is incurable.”

Judges therefore ruled that Sharia law — specifically the ban on men in female clothing — puts transgender women in an “untenable and horrible situation.”

So far, this ruling only applies in their home state, Negeri Sembilan, a flat, industrialized area outside the capital of Kuala Lumpur.

But Sharia codes are fairly consistent across all of Malaysia’s states. This ruling, Johan says, could kick off a domino effect in which transgender Muslims challenge Sharia’s cross-dressing laws throughout the country. (Transgender Malaysians who aren’t Muslim enjoy more protection; Islamic law is only enforced on those labeled as “Muslim” on state IDs.)

Malaysian cops can be a menace to transgendered people. Evidence gathered by Human Rights Watch reveals a litany of horrors they sometimes endure in police custody including fondling, poking genitals with batons and outright rape.

However demeaning, transgender Malaysians might find it easier to ward off police abuse if they ask doctors to deem them mentally abnormal.

“To rely on this groundbreaking case,” Johan says, “they’d need to get a medical certificate that says, ‘This person suffers from gender identity disorder.’”