Indonesia's incumbent president, Joko Widodo, poses for a selfie ahead of elections this week.Willy Kurniawan / Reuters

The shabby headquarters of Indonesia’s general-election commission in central Jakarta is an unlikely bastion of democracy. But it is from here that the KPU, as it is known, will soon execute the world’s most complicated single-day election.

The logistical challenges are breathtaking. Six million election workers have been recruited and trained to oversee more than 810,000 polling stations spread across hundreds of islands. The polling staff will travel by airplane, boat, and foot, from isolated mountain villages to tiny islets. Their mission is to ensure that Indonesia’s 193 million voters can freely and fairly select a president, parliamentarians, and local legislators.

The task of holding free and fair elections in a single day across a vast and diverse geographic expanse might seem to be merely procedural, yet it is crucial to the functioning of a democracy. It is a logistical feat that illustrates many of the oft-hidden processes that, beyond the simple act of casting ballots, underpin democratic societies. And it is one that many countries have struggled with.

This year alone, Nigeria and Afghanistan have been forced to delay their elections, because of logistical problems. In Thailand, the country’s military junta tilted the rule book for March elections in its favor, but its meddling did not stop there—allegations arose of widespread irregularities in the counting process, and the Thai election commission has now postponed the release of results until May, adding to the uncertainty. (India’s parliamentary elections, which are currently under way, are an accomplishment of another sort, organized over several weeks with an electorate nearly five times the size of Indonesia’s.)

Since the fall of the Suharto regime in 1998, Indonesia has developed a good track record for organizing free, fair, and peaceful elections, notable for a country that is beset by corruption, poor infrastructure, and bureaucratic incompetence. Indeed, the incumbent Indonesian President Joko Widodo was only able to rise from relative obscurity to become the leader of the world’s third-biggest democracy largely because of his country’s competitive elections.

All told, Wednesday’s polls will see more than 245,000 candidates running for more than 20,000 seats, as well as the headline contest between Jokowi, as the president is known, and his challenger, Prabowo Subianto.

Burdened by a long history of military rule, and an abortive attempt at electoral democracy in the 1950s, Indonesia’s voting system has been designed to make it hard to steal elections. The key to curbing manipulation is the large number of polling stations, each of which caters to only a few hundred voters, as well as the fact that initial counting takes place in the open. Indonesian voters choose candidates by using a metal nail to pierce a hole in the ballot paper, and soon after the polls close at 1 p.m. on Wednesday, election workers will begin counting tallies by holding each one up so that those present can see the light shining through the hole. While this task is quickly completed at each polling station, the process of counting and checking all the votes nationwide takes about one month. The transparent process at each polling station, however, allows survey organizations to conduct their own “quick counts.”

At the last presidential election, in 2014, the KPU also uploaded the results from each polling station to its website, allowing a civic-minded group of Indonesian techies to conduct its own full count. The collective, called Kawal Pemilu, or “guard the election,” played a vital role in maintaining faith in the system, after Prabowo (who unsuccessfully challenged Jokowi in those polls) claimed erroneously that the vote had been stolen. Kawal Pemilu will be watching again this year.

The process, of course, is far from infallible. Supporters of Prabowo have been spreading disinformation through social media that is designed to undermine confidence in the KPU’s impartiality. Vote-buying is widespread, with one in three Indonesians having accepted cash, rice, or other daily goods as an inducement to support a certain candidate, according to one study. Still, with secret balloting, candidates and their agents have no way to ensure that people will do as they are asked. (There is an exception to secret ballots, in remote areas of Papua, where Indonesia’s Constitutional Court has allowed community voting out of respect for traditional custom. There, village heads sometimes sell their community’s votes to the highest bidder, leading to absurd turnouts of 100 percent in some areas. But at the national level at least, such manipulation barely makes a dent in the overall results.)

And beyond election day, Indonesia’s political system faces plenty of problems. Jokowi, the front-runner, has been a poor guardian of democracy, with a single-minded focus on economic development that has come at the cost of much-needed political and legal reform. To maintain power, he has sought compromises with corrupt politicians, intolerant religious leaders, and former generals. As a result, human rights, the rule of law, and the protection of minorities have all weakened on his watch. Prabowo hardly inspires confidence on these issues, either, as a former general and son-in-law of Suharto with a fiery temper and allegations of past human-rights abuses hanging over his head.

Taking account of these deeper structural problems, it is easy to dismiss Indonesia as a “procedural democracy.” But not that many countries moving out of decades of military rule can get the procedures right. And contestable elections—where the government genuinely fears being thrown out of office—are a cornerstone of a real democracy.

The political elite exerts an uncomfortable degree of control over the system much of the time. But on election day, power goes back to the people.

Just ask Munafri Arifuddin, who ran unopposed last year to become mayor of Makassar, a city of more than 1 million people on the island of Sulawesi. The electorate’s response? It voted by a proportion of 53–47 for none of the above, forcing a rerun of the election next year.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.