“In Indonesia, Salafi ideology has penetrated urban and rural, civil servants and villagers,” said Din Wahid, a theologian at Syarif Hidayatullah State Islamic University. “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.