Indonesian President Joko Widodo speaks in Jakarta, Indonesia, on Wednesday. (Achmad Ibrahim/AP)

HERE’S SOME cheering news for those worried about the state of democracy: An estimated 1.1 billion people — or 15 percent of the Earth’s population — voted or will be voting this month and next in elections in India and Indonesia, the world’s second- and fourth-most-populous countries, respectively. In each, campaigns for national leaders have been competitive and the balloting is expected to be broadly free and fair.

Though the outcomes cannot be predicted with surety — another good thing — the betting is that the result will be the reelection of two incumbents, Indian Prime Minister Narendra Modi and Indonesian President Joko Widodo, who are widely regarded as competent, personally uncorrupt and dedicated to improving the lives of the poor.

Unfortunately, that’s not all the two leaders have in common. Though both were elected in 2014 on reformist platforms, Mr. Modi and Mr. Widodo have since turned to nationalism and sectarianism to retain support. The result has been a troubling erosion of tolerance and other democratic norms in both countries, and the strengthening of religious extremists.

Mr. Widodo won his first election with strong support from the tenth of Indonesians who are not Muslim. One of his closest allies was Basuki Tjahaja Purnama, known as Ahok, an ethnic Chinese Christian who was governor of Jakarta. Yet in Wednesday’s vote, Mr. Widodo’s vice-presidential running mate was Maruf Amin, a militant Muslim cleric who successfully campaigned for Mr. Purnama to be jailed on trumped-up blasphemy charges. Mr. Amin advocates the imposition of sharia law in Indonesia and favors the persecution of gay people.

That’s not the only shift Mr. Widodo has undertaken. He also has appointed retired generals from the powerful military to senior government positions and last year oversaw the suppression of peaceful rallies by opposition activists. Civil society and human rights groups that once supported his presidency called on their supporters to cast blank ballots in this election.

Mr. Modi has always been an adherent of Hindu nationalism, but many who voted for him in 2014 hoped he would set aside sectarian issues and focus on improving the economy. Though he did undertake several reforms, he avoided needed action on labor and land regulations, with predictable results: Unemployment has risen to the highest rate in 45 years.

Meanwhile, Hindu chauvinism has grown steadily during Mr. Modi’s term — there have been scores of hate attacks on Muslims, most of which have gone unpunished — and the election campaign of the ruling Bharatiya Janata Party, or BJP, has leaned heavily on crude sectarian appeals. Mr. Modi has derided Rahul Gandhi, the leader of the rival Congress party, for allegedly running away from Hindu districts to those where “the majority is a minority.” Journalists critical of the government have been pressured and intimidated.

India, like Indonesia, remains far freer than most of its neighbors and thus a natural partner of the United States. But India and Indonesia have not been immune to the currents of populism and nationalism challenging liberalism in the West. We can hope that, if reelected, Mr. Modi and Mr. Widodo will ratchet back their rhetoric and restrain their more extreme followers. For now, their drift toward intolerance reflects a global tide.