YOGYAKARTA, INDONESIA—As the sun went down behind the Prambanan Temple, a short drive from the Indonesian city of Yogyakarta, Ali Nur Sotya wolfed down his nasi goreng.

Like any other devout Muslim, the 30-year-old had just spent another day of Ramadan observing his fast. The day’s work done, he had now come for his evening job—a dancer in the 10th century Hindu temple’s Ramayana ballet.

Sotya is part of a troupe of over 100 dancers performing the Indian epic three nights a week, against the backdrop of one of Southeast Asia’s biggest Hindu temples.

In Indonesia, the Ramayana ballet has been running continuously since 1961.

In Indonesia, the country with the world’s largest Muslim population, this Ramayana ballet, performed in the Javanese style—a finessed form, associated with slow and deliberate movements—has been running continuously since 1961. In 2012, it was anointed by the Guinness Book as the most continuously staged performance in the world.

“We are not just Muslim,” said Sotya, who was playing Janaka, Sita’s father, that evening. “We are people of Java. Here we learn Hindu and Buddhist stories, too.”

Java is one of the main islands in the archipelago nation, home to the country’s capital, Jakarta, and almost 60% of its population. The powerful Hindu kingdom of Majapahit flourished here from about the 13th to the 15th centuries, leaving its impact on culture, language and landscape.

Temples in honour of Vishnu and Shiva are scattered through the islands, words from Sanskrit make appearances in the language, and names from the Mahabharata and Ramayana dot establishments and shops across cities. Still, in modern-day Indonesia, Hindus account for less than 2% of the population.

At about 6.30 PM, Otok Fitrianto, a bespectacled young man, arrived backstage and began applying his make-up, sitting cross-legged besides Sotya. Fitrianto, 29, was set to play Laxmana that evening and had been fasting all day, too. He was puzzled when asked why he danced. “Because dance is beautiful,” he said, in Bahasa, Indonesia’s national language. “Beautiful, beautiful.”

Sotya, too, wouldn’t hear anything about fasting coming in the way of performing. “Of course we have the energy,” he said. “We are only fasting 12 hours a day. In Europe it would be 15 hours.”

Nearby, Damar Kasyiyadi, 28, who was to play the monkey warrior Sugreeva that evening, was changing into costume. “In Java, Islam is very blended,” he said. “Muslims are Muslims with Hindu influence.”

Kasyiyadi, Sotya and Fitrianto moonlight as dancers, but in their day jobs all three are teachers. Sotya and Fitrianto were born to parents who were themselves dancers.

“In Java, Muslims are Muslims with Hindu influence.”

Performed in an open-air, amphitheater-style stage against the illuminated temple, the two-hour show starts at 7.30 PM, featuring sub-titles on a screen, in Bahasa and English, and costs between IDR 100,000 and IDR 250,000 (about $7.5-$19) for a single ticket. The version of the Ramayana depicted would be largely familiar to Indian audiences, except for some name variations or minor differences.

Backstage, the room was pungent with the air of burnt tobacco. The manager, Sumardi, who goes by one name, sat in front of the mirror, drawing deep on his cigarette from time to time. He laughed when asked why a Muslim would be so invested in Hindu epics. “Java culture is not possible without Ramayana and Mahabharata,” he said. “These are not only Hindu stories. Indonesia has many cultures, all existing in harmony.”

What is this culture that everyone in Java speaks of? In the nation’s most populous island, syncretism is locked into the DNA. It is bizarre for the Javanese to think of their religion and their cultural history as incompatible; Hindu stories are part of their legacy, even though their religious affiliation might lie elsewhere.

It is unclear how Hinduism arrived in Indonesia, but it had taken hold by the 5th century. As it flourished, Hindu and then Buddhist rulers controlled several island kingdoms until the 12th or 13th centuries. Meanwhile, Islam had been slowly arriving in waves over the centuries through trade, consolidating its hold to some extent by the 15th century, with sultanates then proceeding to dominate.

Indonesia officially recognises six religions, including Hinduism, which made it to the list in 1962, and whose adherents are largely located in Bali, Java and Lombok. The Parisada Hindu Dharma Indonesia, a representative religious body, has existed since 1964, working to preserve Hindu customs and establish ties with Hindus elsewhere.

Though Bali is the heart of Hindu Indonesia, Java continues to have several Hindu and Buddhist temples, including the magnificent Borobudur Temple complex, the world’s largest Buddhist temple. Hinduism is encoded into the Javanese cultural fabric through the arts, including Wayang kulit, the traditional shadow puppet shows, which feature episodes from the Hindu epics and myths. Wahyudi Sastradinama, 60, a puppet maker in Yogyakarta, spoke of it as a “city of tolerance”. Like most others, he, too, has been fasting and praying during the holy month, and continuing to shape and paint his beloved puppets as always. “Culture and religion are separate for me,” he said.

“It’s not made from cow’s skin. We respect Hindus for whom it is a holy animal.”

Rama, Shinta (Sita) and Gatotkaca (Ghatotkacha) lay in his little work station near the local museum, all made from buffalo skin leather. “It’s not made from cow’s skin because we respect Hindus for whom it is a holy animal,” he said.

In Solo, a city of about 500,000 people an hour’s train ride outside Yogyakarta, at a government office outside one of the main streets, a long banner exhorted people not to join ISIS. Solo is infamous as the location where the Bali bombers first planned the 2002 terror attack on the island, killing more than 200 people.

Despite Ramadan, the nightly Wayang Orang, the Javanese dance form, continues to be staged at the city’s main theatre.

The performance begins at 8 PM—a delay of an hour from the regular timing—to allow the dancers to break their fast. What follows is a two-hour enactment from the Mahabharata featuring spirited battle sequences, a lengthy comic interlude, and an opening half-hour of pure gamelan music.

Tresno Sutrisno, 42, who has been dancing since he was six years old, played Krishna one July evening, after attending prayers at the local mosque. “We are professional artists,” he explained after the show. “Not Hindu or Muslim artists.” One of the woman dancers in the background took off her make-up and put her pink hijab back on.

We welcome your comments at ideas.india@qz.com.