Oblivious to the oppressive heat and the smoky emissions from the stalled traffic, a middle-aged Indonesian couple ambles up and down the pavement outside the office of the governor of Jakarta.

Garment merchant Pak Eeng and his wife Ade are out-of-towners from the neighbouring island of Sumatra. They had taken a boat and a bus, travelling overnight and through the day to the capital city, partly to meet with suppliers but also to pay their respects to a defeated politician.

WATCH: Widodo’s message to Indonesians working in Hong Kong

Since the gubernatorial election last week, row upon row of floral tributes to the incumbent has sprouted in front of the governor’s office. Ade, 55, stops for a picture. Her 58-year-old husband nods in approval and taps his camera phone. Her red-and-white headscarf picks up the red carpet of roses on a banner reading: “One defeat, one thousand flowers will bloom. Thank you Ahok!”

Basuki Tjahaha Purnama, or Ahok as he is popularly known, will have to vacate the post in October after being soundly beaten by former culture and education minister Anies Baswedan.

WATCH: Widodo speaks to SCMP on Chinese investment in Indonesia

Although only a municipal election, the event took on far greater significance, as a possible bellwether of Indonesia’s young democracy and its openness towards its neighbours – including a China eager to pump massive investments into the country.

Basuki is Chinese and a Christian in the world’s largest Muslim-majority country. He is also an ally of President Joko Widodo, having served as Widodo’s deputy when Widodo was Jakarta governor.

Basuki’s popularity had been seen as an indicator of Indonesians’ appetite for effective government and rational economic policies over the visceral pulls of identity politics. Conversely, his defeat after a campaign marred by hardline religious appeals has upset many people inside and outside the country – including this Muslim couple from Sumatra. “I just want to express my sympathy for Ahok,” says Ade, a bespectacled mother of three.

What if Ahok’s loss in the Jakarta election wasn’t all about Islam and anti-Chinese feeling?

Basuki’s religion is a non-issue for them. It’s a question of peribadi, Ade says, using an Indonesian term that indicates a personal and private matter. “We all take different paths to God.”

That, however, was evidently not how the majority of Jakarta voters were persuaded to weigh what was at stake. For the past six months, Basuki has found himself on the defensive against accusations that he had blasphemed against Islam. Speaking at one campaign event, he had forthrightly stated that if voters wanted to believe the lie that their religion forbade them from electing non-Muslim leaders, they should go ahead and vote against him.

Hardliners sniffed an opportunity and pounced, twisting his words to accuse him of claiming that the Koran was lying to Muslims. He was charged with violating Indonesia’s sweeping blasphemy law, for which he is still under trial. The radical Islamic Defenders Front also orchestrated a public demonstration numbering almost 200,000 protesters.

When he first took office, Basuki had threatened to take action against the organisation for its use of intimidation and violence. The Front and other hardliners had the last laugh when his more malleable challenger Anies Baswedan scored his resounding victory.

Jakarta’s ethnic Chinese leader is gone, is it Widodo next?

Anti-Chinese sentiment is not new to Indonesia. The ethnic Chinese minority is tiny, making up an estimated 1.5 per cent of the population. Many Chinese Indonesians are humble merchants and farmers, but enough of them, including some of the country’s richest tycoons, are disproportionately and visibly wealthy to make them a sore point. Ethnic Chinese were targeted in Jakarta riots that accompanied the downfall of the Suharto regime in 1998.

When Basuki was elected deputy governor of Jakarta alongside Widodo in 2012, the event was viewed as a moment of healing in the city’s relationship with its Chinese population. He was elevated to the governorship when Widodo became president, despite opposition from groups like the Islamic Defenders Front – again suggesting that Indonesia was entering a new era of stability.

Now, however, the ease with which ethnic and religious suspicions were activated against even a popular incumbent is reviving doubts about Indonesians’ tolerance of diversity.

WATCH: Widodo’s message to Hong Kong investors

This time, the potential targets are not just local citizens and businesses but also foreign investors – in particular the big wave of investments from China.

Indonesia and China are on the brink of cultivating a sizeable economic partnership.

Widodo, who will meet business leaders in Hong Kong on Sunday, has embarked on an aggressive infrastructure development agenda. His administration has tried to slash Indonesia’s notoriously cumbersome red tape and drain rent-seeking from the system.

China, meanwhile, is on the hunt for new markets. With Indonesia’s investment climate improving in recent years, Chinese foreign direct investment grew four-fold last year, to reach a record US$2.7 billion.

Zhang Min, chairman of the China Chamber of Commerce in Indonesia, does not expect the pace to let up. “As I continue to see more Chinese companies coming to Indonesia to find out more about the business environments here, I foresee the growth in investment will be huge in the coming five years,” he says.

WATCH: Jakarta rally turns violent as Muslim hardliners attack police

In 2013, President Xi Jinping (習近平) became the first foreign leader to address the Indonesian parliament. He chose the occasion to propose the setting up of the Asian Infrastructure Investment Bank, a key initiative in his government’s bid to play a bigger role on the world stage.

Widodo wants Chinese to keep coming – as investors, not workers

Last year, 31,000 workers from China arrived in Indonesia to start up new plants such as in smelting, cement and power plants. Chinese entrepreneurs are also arriving in search of opportunities. Half of the projected 20 million tourists expected to arrive in Indonesia in 2019 will be Chinese.

Chinese money is funding a long list of infrastructure projects in Indonesia, from ports, to roads and railways.

In downtown Jakarta, China Sonangol – which began its foray overseas in Angola – is building one of the country’s tallest buildings, at 303 metres. Not all the projects grab headlines for the right reasons. The high-speed railway project linking Jakarta to Bandung in West Java has been stalled by disputed land rights, more than a year after its ground-breaking ceremony witnessed by Widodo himself.

Predictably, the influx of Chinese money and manpower has provoked some anxiety among Indonesians. Last December, more than a 100 undergraduates in Sulawesi, where Chinese nickel smelters are being built, blocked trucks they suspected of transporting illegal Chinese workers.

When Indonesian authorities launched new currency notes, there were even accusations that they looked too similar to Chinese money. The country’s hyperactive social media went into overdrive, with one piece of fake news claiming that the commander of the Indonesian armed forces had complained that “communist China has started to meddle” in the country.

Exclusive: Widodo’s peace formula for South China Sea

But talk of Indonesia coming under Chinese hegemony is probably far-fetched, underestimating the Southeast Asian giant’s own heft and political wiliness in handling its diplomacy. Indonesia does not want nor need to get too close to any big power, say experts.

Christine Susanna Tjhin, of Jakarta’s Centre for Strategic and International Studies, says: “In order to maintain a certain degree of strategic autonomy, Indonesia cannot depend too much on any major power – particularly a country like China, with which Indonesia has a dramatically complex history.”

Asked about its relations with China and the United States, Widodo says: “Our foreign policy is based on the belief that we can be friends with any party on the basis of mutual benefit. This is our principle.”

In an exclusive interview with This Week in Asia ahead of his visit to Hong Kong and Beijing, Widodo downplayed the political risks surrounding the rush of Chinese investments into his country.

“In a country as big as Indonesia, these small problems shouldn’t be magnified,” he says. But he also stressed that Chinese companies must do their part to minimise that risk, by localising their workforce and transferring expertise.

Widodo cites Hong Kong companies as a positive example. “They respect our law, our culture, our society,” he says. In his indirect, Javanese fashion, he hints that Chinese companies should do the same.

Jokowi still needs to tread carefully while engaging China
Christine Susanna Tjhin, analyst

Clearly, Indonesia needs to manage perceptions, not just the reality, of its relations with China.

Tjhin said the ambivalence and occasional anger over China’s investments indicated the “low level of trust” that the Indonesian public had towards its giant Asian neighbour. “Jokowi still needs to tread carefully while engaging China,” she says, using a nickname for Widodo.

The China Chamber of Commerce’s Zhang Min is similarly tentative but not alarmist. “There won’t be a big impact as long as the political situation is stable, and there is still potential for economic growth,” he says. “If Indonesia turns to protectionism or xenophobia, then the impact will be [great].”

Anxieties about a rising China are, of course, not unique to Indonesia. The additional factor, though, is the country’s simmering religious intolerance, which is where last week’s election raises a red flag.

“During the recent Jakarta Governor election, unfortunately certain groups did whip up anti-Chinese and hardline Muslim sentiments, to be used as political weapons,” says Thomas Lembong, chairman of Indonesia Investment Coordinating Board and an ethnic Chinese himself.

“However, those tactics only worked because during the campaign, incumbent Governor Ahok often displayed some of our worst traits as elite ethnic Chinese-Indonesians: confrontational, aggressive, brash. It’s a wake-up call for us elite ethnic Chinese-Indonesians, to be more attuned to Indonesian culture, which is soft-spoken and very respectful.

“We need to make sure, that Chinese investment into Indonesia, which is soaring and which is bringing massive benefits for the Indonesian economy, does not fall victim to our failure, as elite ethnic-Chinese Indonesians, to be better citizens.”

And while the open hate speech against non-Muslims during the campaign was troubling, observers as well as officials say it would be a mistake to extrapolate from the election and predict that Islamists will take over and slam shut Indonesia’s doors.

Businessmen on the ground appear to be taking the election tensions in their stride, according to Tjhin. While there remain “concerns over safety and stability in Indonesia”, she does not yet find indications of a serious decline of interest from Chinese companies and the government.

Intense media narratives aside, the big anti-Basuki rallies and the election itself were relatively peaceful, she points out. “Most of the Chinese business people that I spoke to are more concerned with consistencies in laws and regulation, especially related to investment and labour, rather than the identity politics,” she says.

Then there is the speculation that Basuki’s defeat presages Widodo’s own downfall against a rising tide of Islamism when he fights for re-election in 2019.

In his first presidential election, Widodo had a close shave against Prabowo Subianto, the former son-in-law of the late strongman ruler Suharto. In the Jakarta governor’s race, Prabowo backed Anies Baswedan in what was widely seen as a proxy battle ahead of a return match against Widodo in 2019. When asked about 2019, he laughs, offers his serene, inscrutable smile and declares: “I am focused on the work. I am going to continue working. I have never thought about the politics, that’s too far ahead.”

Still, too far ahead or not, the talk continues. But Kevin O’Rourke, a long-time Indonesia analyst, is not persuaded that what happened to the Jakarta governor will happen to the Indonesian president. He believes Widodo will prevail against his old foe.

“Widodo will have far better prospects for winning the moderate mainstream, as he himself is very well known by now as being quintessentially mainstream,” he says. “In the national election, I expect that religious identity will matter far less than economic conditions, especially food price stability and employment trends.”

How the Australian SAS raised the ghosts of Indonesia’s brutal past

Whatever his true sentiments, Widodo himself does a convincing job of appearing unperturbed. He says the morning after the bruising Jakarta election, Anies met with Ahok. “In Indonesia, we have silatulrahmi, or friendship, a coming together. This is normal, in any election, there will be winners, there will be losers,” he says. “In Indonesia, we have bhinneka tunggal ika,” he adds, referring to the national slogan in Sanskrit, which means unity in diversity.

The inflammatory rhetoric and polarisation in the nation’s capital over the past six months were just a show, he suggests. “Everybody knows in the end we can come together and we can live in unity. What is there to worry about?” he says, thrusting his chin assertively, all the while smiling.

If the peace-loving, non-blinkered view of religion of the Sumatran couple Pak Eeng and Ade represents the Indonesian mainstream, Widodo may be right.