Former special forces chief Prabowo Subianto and Jakarta Governor Joko "Jokowi" Widodo are running neck-and-neck in opinion polls, leaving markets in Southeast Asia's largest economy under pressure and on tenterhooks awaiting the outcome.
Indonesia's 190 million voters face a clear choice: the relatively untested, untainted Jokowi or a tough nationalist in Prabowo who has top military leadership experience but is dogged by decades-old allegations of army brutality, which he denies.
"The young democracy of Indonesia is about to face a tough maturity test on July 9," said Wellian Wiranto, economist at OCBC Bank.
This will be the first time in the world's third-largest democracy that a directly elected president hands over the reins to another. Outgoing president Susilo Bambang Yudhoyono, who has largely disappointed in his last four years, must step down in October after serving a two-term limit.
Voting starts in Indonesia's distant eastern islands and finishes two time zones away in the densely populated west at 0700 BST. Early counts by pollsters should give an idea of the outcome fairly soon afterwards.
A Prabowo win is expected to weaken markets due to concerns that he will introduce protectionist policies in the financial and farm sectors, and launch big debt-funded spending projects. Stocks <.JKSE> and the rupiah have fallen about 4 percent since mid-May when Jokowi's big lead in the polls began to slip.
Should the race be too close to call, the markets could take an even bigger hit, particularly if it is a long, drawn-out process involving legal battles, protests and violence.
All eyes are on the main battleground province of West Java, an area the size of the Netherlands but with a population nearly three times larger.
Prabowo has seized a single-digit lead from Jokowi in the province of 46 million people, helped by a smear campaign that raised questions about the Jakarta governor's race and religion -- potent topics in a nation that is 95 percent native Indonesian and has the world's largest Muslim population.
"That had a very big impact," said Fitri Hari, researcher at polling firm Lingkaran Survei Indonesia, referring to questions, aired in social media by Prabowo supporters, about Jokowi's Islamic faith and his Javanese ethnicity - even though he was born a Muslim in the Javanese town of Solo.
To counter the smear, Jokowi is set to go on a minor pilgrimage to Saudi Arabia early this week when there is a ban on public campaigning before the vote.
Jokowi's lead in national opinion polls -- as much as 30 percentage points three months ago -- has shrunk as the smear campaign has developed, pollsters say. Prabowo, who has not made public comments about Jokowi's race or religion, has appeared to lead a more organized campaign than his rival.
West Java, which represents around 20 percent of the national vote, is home to some of the country's most conservative Muslim groups. One of the Islamic parties backing Prabowo holds considerable sway there.
The province was also the breeding ground for fundamentalist religious groups such as the Darul Islam, which sought an Islamic state in the early independence years, to the Jemaah Islamiyah, which was behind the Bali bombings in 2002 and 2005.
"Jokowi is more of a manager. He pays attention to the operational side of things ... but this country needs somebody with real leadership talent, a visionary. I think that's Prabowo," said Yanti, a 42-year-old resident of West Java's port city of Cirebon.
Jokowi spent the last days of the campaign visiting mosques and meeting farmers throughout West Java to counter the damaging attacks on his image. Prabowo made similar stops in the area, reflecting the province's importance in a close election.
"We stopped by in a mosque this afternoon and (Jokowi) joined the prayer. Everyone saw him praying and the immediate reaction was 'Oh, so he is a Muslim'," said Anies Baswedan, a spokesman for Jokowi's campaign, speaking at a campaign stop in West Java's capital city of Bandung.
With public campaigning banned three days before Wednesday's elections, candidates are turning to religious leaders to canvass support through their sermons in a last-ditch effort to grab the few remaining undecided voters in West Java.
In Tasikmalaya, religious leader Bunyamin Ruchiyat said he would be dropping hints to his followers on who to vote for.
"Jokowi is honest, humble and a down-to-earth figure. Those are the traits that we should vote for," he said.- Reuters