KUALA LUMPUR, Malaysia — Two Malaysian Muslim women convicted under Islamic laws of attempting to have sexual relations were caned Monday in a rare public whipping that was slammed by rights activists as a grave miscarriage of justice.

Lawyers and activists said the women, aged 22 and 32, were seated on stools facing the judges and given six strokes from a light rattan cane on their backs by female prison officers. More than 100 people witnessed the caning in a Shariah courtroom in northeast Terengganu state, they said.

Muslim Lawyers' Association deputy president Abdul Rahim Sinwan said unlike caning under civil laws, the punishment under Islamic laws isn't painful or harsh and was meant to educate the women so they will repent. The women, dressed in white headscarves and clothing, didn't cry or scream but "showed remorse," he said.

The Morning Rundown Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"Repentance is the ultimate aim for their sin," he said.

Human rights groups slammed the punishment as a setback to human rights and said it could worsen discrimination against people in Malaysia's lesbian, bisexual, gay and transgender community.

"Caning is a form of cruel, inhuman and degrading treatment and may amount to torture," Amnesty International Malaysia said in a statement. "People should not live in fear because they are attracted to people of the same sex. The Malaysian authorities must immediately repeal repressive laws, outlaw torturous punishments and ratify the U.N. Convention Against Torture."

Malaysia follows a dual-track justice system. Nearly two-thirds of Malaysia's 31 million people are Muslims, who are governed by Islamic courts in family, marriage and personal issues. The two unidentified women were discovered by Islamic officials in April and sentenced last month by a Shariah court to six strokes of a cane and a fine after pleading guilty.

Thilaga Sulathireh, from the group Justice for Sisters who witnessed the caning, said she was shocked by the public spectacle. She said Malaysian laws were inconsistent because civil laws prohibit corporal punishment against female prisoners.

"It's a regression of human rights in Malaysia. It's not about the severity of the caning. Corporal punishment is a form of torture regardless of your intention," she said.

Malaysia is seen as a moderate and stable Muslim-majority country, but Islamic conservatism is on the rise.

The caning occurred amid a climate of fear and discrimination against Malaysia's lesbian, gay, bisexual and transgender community. A few weeks ago, authorities removed the portraits of two LGBT rights activists from a public exhibition. Malaysia religious minister Mujahid Yusuf later said the government doesn't support the promotion of LGBT culture. A transgender woman was also beaten up by a group of people in a southern state this month.

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM