JAKARTA, Indonesia — Joko Widodo, the Muslim president of Indonesia, is into heavy metal and saving Christians.
Earlier in his political career, he helped to shelter ethnic Chinese Christians during deadly rioting. And upon winning the presidency in 2014, Mr. Joko filled his cabinet with women and banned a radical Islamic group that calls for Islamic law to replace Indonesia’s democracy. His election was seen as a victory for the moderate Islam that has long flourished in this country.
But this time around, as he runs for re-election on Wednesday against a pugnacious former general who has embraced the language of hard-line, Middle Eastern Islam, Mr. Joko is veering rightward.
At a Saturday campaign rally, he pointedly gave thanks to Muslim preachers, and on Sunday he visited Mecca. For his vice-presidential running mate, Mr. Joko chose Ma’ruf Amin, the 76-year-old head of the Indonesian Ulema Council, which has issued fatwas against homosexuality and the wearing of Santa hats by Muslims. No hip-gyrating traditional dancing, no premarital sex and certainly no headbanging heavy metal allowed.
Nearly 5,000 miles from the birthplace of Islam, Indonesia, the nation with the largest Muslim population in the world, has been widely seen as proof that Islam and democracy can coexist and prosper.
“Indonesia is a country with more than 260 million people, with a geographical area of at least 17,000 islands,” Lukman Hakim Saifuddin, Indonesia’s minister of religious affairs, said in an interview. “People still treasure and respect the diversity, the differences.”
Yet as the Muslim world has wrestled with Islam’s role in modern society, Indonesia, too, has engaged in a national spiritual reckoning. In recent years, the country’s Muslim majority has embraced more overt signs of religiosity and shifted toward Arab-style devotion: flowing clothes and veils, Arabic names and Middle Eastern devotional architecture.
Most of all, a puritanical Salafist interpretation of Islam, which draws inspiration from the age of the Prophet Muhammad, is attracting followers in Indonesia. Bureaucrats steeped in austere Wahhabism draw converts in government prayer halls. Hundreds of Indonesians joined the Islamic State in Syria and Iraq, and hundreds of thousands more cheer for the group on social media.
Pushed aside are the syncretic traditions that were long the hallmark of Indonesian Islam, a blending with indigenous beliefs that gave the faith its distinct local flavor.
“In Indonesia, Salafi ideology has penetrated urban and rural, civil servants and villagers,” said Din Wahid, a theologian at Syarif Hidayatullah State Islamic University who has studied the rise of puritanical Islam in Indonesia. “They see corruption all around them and say that it is only Shariah and restoring a caliphate that will be able to fix society.”
Mr. Joko’s opponent in the election on Wednesday, Prabowo Subianto — the European-educated son of a Christian and a connoisseur of fine wines — may seem an unlikely figurehead for hard-line Islam. But he is an astute politician who has shouted for jihad and vowed to welcome home from self-imposed exile Rizieq Shihab, the head of the Islamic Defenders Front, which gained notoriety for attacking nightclubs in Jakarta, the capital, and calling for Shariah law.
“Political Islam has strengthened tremendously over the last two decades in Indonesia,” said Andreas Harsono, an Indonesia researcher for Human Rights Watch and author of the new book “Race, Islam and Power.” “We should be very concerned because both sides in the campaign have now made human rights and democracy decline.”
Faith politics exploded in late 2016 when millions of Indonesians marched in the streets of Jakarta to protest what they considered blasphemous language from Basuki Tjahaja Purnama, a Christian who was then the Jakarta governor. Mr. Ma’ruf, Mr. Joko’s surprising choice of running mate this year, was one of the drivers of those protests.
Mr. Basuki, widely known as Ahok, was jailed for 20 months. Mr. Joko declined to defend his former deputy.
“Ahok’s downfall was because of populism, like Trump or Brexit,” said Zuhairi Misrawi, a researcher for Nahdlatul Ulama, the world’s largest Islamic social organization, which promotes moderate Islam. “Now, political parties are aiming to get more votes by showing how Islamic they are, and it is changing our Indonesian political identity.”
Even Mr. Lukman, the religious affairs minister under Mr. Joko, tries to thread the needle on the role of faith in Indonesian society. “Indonesia is not officially an Islamic state,” he said, sitting in an office decorated solely with Muslim art. “But Indonesia is also not a secular state.”
Islam arrived in Indonesia through Arab and Indian merchants. By the 16th century, the faith had displaced but also cross-pollinated with Buddhism, Hinduism and animist faiths.
Most Muslims here still practice a fusion form of the faith. Traditional Indonesian mosques had thatched or pitched roofs, reminiscent of Hindu temples. Indonesian Muslim festivals feature offerings of flowers to volcanoes. The national dress for women includes a lacy, body-hugging blouse.
Beginning in the 1980s, Saudi money began changing the look of Islam in Indonesia. Open-air mosques were replaced by marble, domed edifices. Today, thousands of mosques around the country bear Middle Eastern motifs attesting to their Saudi, Qatari or Kuwaiti funding.
“Our duty to Islam is to follow the true, pure path that is not spoiled by local traditions,” said Dharma Gesuri Wallad, who used to live in the United States but now worships at a South Jakarta mosque marked by a large black cube, like the one in Mecca, atop an old shopping mall. “People from here, they see an Islamic preacher with a beard, and they think it is beautiful. But in the U.S., they think we are all terrorists.”
Perhaps the most influential Saudi investment in Indonesia is the Institute for the Study of Islam and Arabic, known by the Indonesian acronym Lipia, where classes are segregated by gender and teach the fundamentalist Wahhabi theology that dominates in Saudi Arabia.
“Even though Indonesian Islam is a syncretic, cultural Islam, we are taught that anything from Saudi, the country of Mecca and Medina, must be authentic and good,” said Ulil Abshar Abdalla, the coordinator of the Liberal Islam Network, who studied at Lipia.
The university has produced some of Indonesia’s most renowned Islamic scholars. But it has also nurtured militants linked to terrorist attacks across Southeast Asia. Over the past two years, Lipia has expanded across the country, opening at least three new campuses in a country with a shortage of universities.
In December, the former Saudi ambassador to Indonesia, Osama Mohammad Abdullah al-Shuaibi, referred on Twitter to the moderate Nahdlatul Ulama, which has at least 50 million members, as a “deviant organization” that was insufficiently pious. The month before, he spoke approvingly of Mr. Rizieq displaying in Mecca the black flag associated with the Islamic State.
More mainstream Indonesian Muslim leaders resent the inroads that Saudi-inspired Salafism has made here.
“Wahhabism is against our culture, and our religion is totally different from the Middle East,” said Mr. Zuhairi of Nahdlatul Ulama, who is helping set up an online presence to compete against the puritanical websites popular with young Indonesians.
“Our war is to get moderate Islam to fight for millennial Muslims who are hungry for Islam,” he said. “But people don’t see us as passionate, as charismatic. It’s hard to change this.”
The flowering of a more conservative Islam in Indonesia accelerated after the overthrow of Suharto in 1998, after more than three decades of corrupt, dictatorial rule. What followed was a federalist exuberance that gave local governments newfound authority. The province of Aceh, for example, is now under Shariah, with public flogging for adulterers or those who drink alcohol.
“Salafism is a magnet for people because it’s very simple and easy to understand,” said Mr. Ulil of the Liberal Islam Network. “It gives the impression that it’s based on prophetic, pure scripture while others, like us, are not authoritative.”
When Zaenal Abidin started building a Salafist community on the outskirts of Jakarta in 1998, three families joined him. Now there are 300, many of them middle-class government employees, who send their children to Mr. Zaenal’s Islamic school.
“We were colonized for so long by Christians, so we have an inferiority complex,” he said. “But this is a country with the world’s largest number of Muslims, so we must show our true Islamic nature.”
At the age of 11, girls in Mr. Zaenal’s commune begin wearing the niqab, which leaves only eyes and hands visible. “Before, people used to look at me strangely,” said Khaulah, a teacher. “Now more people are wearing proper clothes so I don’t get stared at anymore.”
As it has elsewhere in the Muslim world, conservative dress has become more common in Indonesia, with women adopting the veil and men wearing longer beards.
Polygamy and child marriage are also on the rise in Indonesia, as democracy has allowed personal freedoms repressed during the Suharto era to prosper.
“Radical groups understand that they can use democracy to their advantage,” said Musdah Mulia, a professor of Islamic political thought at Syarif Hidayatullah State Islamic University. “They say that democracy is bad because it allows infidels to have a vote, but then they manipulate it for themselves.”