A bitterly fought election to govern Indonesia's capital that has fanned religious tensions has also thrown a spotlight on anti-foreign sentiment, as conspiracy theories swirl about an influx of illegal Chinese workers spurring vigilantism.

Foreign direct investment from China hit a record high of $2.67 billion last year after President Joko Widodo rolled out the red carpet to Chinese investors, who are typically willing to take on risks for infrastructure and other big projects.But the cheap funding comes at a price: Chinese companies often bring in their own workers and machines, creating friction with locals, according to interviews with labour groups, company executives and government officials.

Indonesian investment chief Thomas Lembong said a "freak-out over foreign workers" had been politicised, fuelling tensions surrounding the Jakarta poll, which pits the ethnic Chinese Christian incumbent Basuki Tjahaja Purnama against a Muslim rival.

Purnama is backed by Widodo's ruling party and Lembong said the issue of anti-foreign and - in particular anti-Chinese - sentiment had been harnessed by rivals of the government.

"It's part of a broader effort to turn political sentiment anti-foreigner and anti-Chinese at a time when Chinese investment is poised to be the biggest factor driving the Asian economy," Lembong told Reuters.

The number of Chinese work permit holders jumped 30 percent in the past two years to 21,271 in 2016, the latest data from Indonesia's manpower ministry showed. In comparison, there were 12,490 from Japan and 2,812 from the United States last year.

While the issue had been compounded by discredited reports circulating on social media claiming that 10 million Chinese workers had flooded Indonesia, labour unions still dispute official figures.

Chinese companies have been mis-using a visa-free route meant for tourists to bring in "hundreds of thousands" of low-skilled Chinese workers, said labour leader Said Iqbal.

Since February, the Confederation of Indonesian Workers' Union (KSPI) has been compiling unofficial data on Chinese workers suspected of not having proper documentation and it has asked the manpower ministry to take action, he said.

"Local unskilled labour cannot work because the jobs have been filled by the Chinese," the KSPI's Iqbal told Reuters.

Liky Sutikno, the Beijing-based chairman of the Indonesian Chamber of Commerce in China, said some Chinese companies temporarily bring in their own "technical workers", who would return to China once the local teams take over.

These workers may have a better knowledge of products and processes, on top of being faster in executing steps such as installing machinery, Sutikno said.


VIGILANTISM

Late last year, around 150 college students on Sulawesi island, where several Chinese smelters are being built, stopped vehicles they suspected of carrying illegal Chinese workers and brought them to the authorities.

The group planned more raids this year, said Erik, one of the students, who declined to give his full name.

Maruli Hasoloan, a manpower ministry official, acknowledged some labour friction and vigilantism over the past few months. While the ministry was coordinating with other authorities to prevent any abuse of visa-free entry, it does not condone a vigilante crackdown on foreign workers, he added.

Indonesia has suffered bouts of anti-Chinese and anti-communist sentiment over its history, though this has usually been directed at its minority ethnic Chinese community.

On average, Indonesian Chinese are far wealthier than other ethnic groups. During riots leading to the fall of President Suharto in May 1998, ethnic Chinese were targeted, making up many of around 1,000 people who were killed in the violence.

Under Suharto, Chinese culture and language were severely restricted, but at the same time he cultivated some ethnic Chinese businessmen who became hugely rich.


UGLIER MOOD

The capital Jakarta has seen a series of mass rallies led by hardline Islamists calling for Purnama, Jakarta's first Christian and Chinese governor, to be jailed even as he was put on trial over allegations that he had insulted the Koran.

Purnama, who is competing against former education minister Anies Baswedan, denies what are regarded by critics as politicised charges.

While it is too soon to assess whether all this could have an impact on Chinese investment decisions, some Chinese business groups say they are worried about the uglier mood and also about potentially losing a business-friendly leader of Jakarta.

Many Chinese companies favour Purnama for his perceived ability to execute Widodo's infrastructure reform agenda, which is aligned with Chinese President Xi Jinping's "One Belt, One Road" policy to invest billions of dollars in global projects.

Jakarta, a city of more than 10 million people, accounts for nearly a fifth of national economic output and is home to major construction projects including a $5 billion Chinese-backed rail connecting the capital to the West Java city of Bandung.

The anti-Purnama movement has also revived jitters about the racial and religious under-currents in Indonesia, which has the world's largest Muslim population.

"Chinese concern is stability and consistency of the rule of law," Sutikno said. "What they are scared of the most is a repeat of 1998, that the Chinese will be singled out again."