When Shinta Ratri prays, like many devout Indonesian women she dons a mukena, a long flowing gown often embroidered with colourful and intricate designs. But she finds it hard to do so in most public mosques in this small city on the Indonesian island of Java. The reason, she says, is that she began life as a man.

According to Shinta, transgender people in Indonesia find it hard to pray at ordinary mosques, where men and women are divided and they often elicit hostile reactions from other congregants.

It was for this reason that Shinta helped found the Pondok Pesantren Waria al-Fatah, the world’s only Islamic boarding school for transgender people. “In the public mosque we made people uncomfortable. We needed a safe place for trans women to pray,” she says.

Since its establishment in 2008 the boarding school, or pesantren, has become a safe haven for trans people from across Indonesia, the world’s largest Muslim-majority nation.

“In here you can be with a women’s clothes or men’s clothes, it’s up to you,” Shinta says. “It depends how comfortable you are.”

The school sits in a warren of narrow lanes in a quiet neighbourhood of Yogyakarta, housed in a 19th-century joglo, a traditional Javanese wooden house once owned by Shinta’s grandmother. Its walls are painted bright green; outside in the yard stray cats scavenge and laundry billows in the breeze.

The school has a shifting membership of around 40 mostly LGBT people. Unlike most pesantren, where students are in their teens or early 20s, the students here are generally older, and include four transwomen who live here full-time.

One of them is Yumi Sara, 50. She has lived at the boarding school since 2010, while working as an HIV/Aids advocate in Yogyakarta.

“Allah doesn’t care if you are gay or transgender or anything else,” she says, taking drags on a clove cigarette as the evening call to prayer echoes across the city from nearby mosques. “Transgender is a beautiful creature created by Allah.”

“Making a place like this is a statement,” says Mario Prajna Pratama, the chairperson of Plush, an LGBT rights organisation in Yogyakarta. “It’s like, if you do not want to give us access to pray, we will create our own.”

In Indonesian, trans people are referred to as waria, a combination of the Indonesian words for woman (wanita) and man (pria). Waria are nothing new in Javanese culture, but they nonetheless face persistent discrimination and are often pushed to the edges of society.

Refused jobs by many employers, who require that applicants describe themselves as either male or female, many find work in the arts, as traditional dancers and street performers, or in more dangerous and marginal fields such as sex work.

In addition to holding weekly prayers and Koranic readings, Shinta frequently visits university campuses to educate young people about LGBT issues. But the increasing visibility of the LGBT rights movement has prompted a backlash from political and religious conservatives. Homosexuality and transgenderism are not illegal in Indonesia, but the past year has seen a spike in anti-LGBT rhetoric and actions by the authorities.

Earlier this month police raided a sauna popular with gay men in the capital Jakarta, arresting 51 people. While most were released a short time after, five have been held for violations of Indonesia’s loosely defined anti-pornography laws. A similar raid in May netted more than 140 arrests.

The Indonesian Psychiatric Association has claimed that transgender people have mental disorders, and the country’s parliament is currently debating a law that would ban LGBT characters from national television shows.

In May two gay men were publicly caned in conservative Aceh province for violations of the region’s sharia laws, which outlaw homosexuality.

As with the fundamentalist campaign that led to the jailing of Jakarta’s former governor, Ahok, on blasphemy charges, Pratama says anti-LGBT politics have become a unifying issue for conservatives. “To make them unite, they need an issue. What can make them unite? One of the things is the LGBT,” he says.

Abdurrahman, leader of Front Jihad Islam in Yogyakarta, has spoken out against the school. Photograph: Sebastian Strangio/The Guardian

The Pondok Pesantren Waria al-Fatah has not been immune from the backlash. In February 2016 the school was forced to close for four months after threats of violence from conservative groups, including a local vigilante group calling itself Front Jihad Islam (FJI). After the local authorities proved unresponsive to her appeals, Shinta says she agreed to close the school temporarily.

Abdurrahman, the leader of FJI, claims the boarding school is violating Islamic precepts. “In the Qur’an it is said that men should not behave like women,” he says at his home outside Yogyakarta. “It violates sharia.”

But many local residents are supportive of the pesantren and its mission. One is Arif Nuh Safri, a religious teacher, or ustadh, based at the Institute of Qur’anic Studies outside Yogyakarta, who volunteers his time to take prayer sessions and Qur’anic readings at the school.

Arif says everyone has the right to access religious truths. “When we talk about religion, we talk about humanity,” he says. “If we talk about religion but don’t respect humanity, it’s no use.”