When Ridwan Kamil took over as mayor of Bandung in September 2013, bureaucrats like Tammi Lasmini, who would be responsible for executing plans to rebuild the city centre and spruce up its parks, admitted to having their doubts.

Just a month earlier Kamil’s predecessor, Dada Rosada, had been arrested on suspicion of bribing judges – charges that ultimately led to a 10-year prison sentence. A Dutch colonial hill top town and capital of Indonesia’s West Java province, Bandung was one of the few tourist attractions near Jakarta. But its charm had crumbled into a mess of rubbish and potholed sidewalks. Things got so bad a blogger in 2014 called Bandung “A City of Pigs”, a jarring wake up call for this overwhelmingly Muslim-majority city.

Can Indonesia’s new cybercrime unit win its war on fake news?

“We have had plans for infrastructure or to improve the environment. But we didn’t have the political will. But then he came,” says Lasmini, who heads the city’s spatial planning department, referring to Kamil.

Four years later and Kamil has his eyes on the governorship. He has shot to national attention not only by splashing out on a vast urban facelift but also by sawing through city bureaucracy by putting budgeting online and arming residents with apps that let them lodge complaints or apply for business permits.

“This is like a dream that I’ve had for a long time,” Lasmini says

West Java is just one of 17 provinces going to the polls in June. As voters mull the candidates a track record of reform – even the one of dreams – isn’t enough. Increasingly religious issues matter, too. Kamil has teamed up with a local government official hailing from one of Indonesia’s main Muslim parties to help inoculate him from criticism that the moderate Muslim isn’t pious enough. The race is shaping up as a showcase of the new normal in Indonesian politics where candidates must burnish their religious as well as their reformist credentials.

Sex before marriage ‘fudge’ gives hope to Indonesia’s persecuted gays

“You have to do both,” says Yenny Wahid, director of the Wahid Foundation, a religious affairs think tank, based in Jakarta.

“People have learned from the Jakarta election how damaging religious attacks can be. Now politicians must at least seem to be trying very hard to cater to the views of the religious right.”

In the that race the reformist Basuki Purnama, better known as Ahok, was defeated in a landslide. A Christian of Chinese descent, Mr Ahok was later jailed for insulting the Koran.

By comparison in West Java, the candidates have taken pains to appeal to nationalists and the devout. Kamil’s main opposition is the sitting vice-governor, Deddy Mizwar, who has helped fan resentment toward religious minorities, especially Shia Muslims. Last year he appeared before a gathering of the National Anti Shia Alliance to warn that the sect were “dangerous” and may influence this year’s regional election.

How Indonesia (finally) fell in love with man’s best friend

By contrast his running mate, Dedi Mulyadi, is a champion of Sundanese identity and widely regarded as pluralist.

By comparison, when he was vying for the governorship of Jakarta, President Joko Widodo’s running mate was Ahok. Jusuf Kalla, Widodo’s current vice-president is from the nationalist Golkar party. As Kalla steps aside ahead of next year’s vote, Widodo may consider plucking a more religious running mate, Ms Wahid says.

“The smart choice would be someone from the Islamic parties.”

For his part Kamil’s running mate, Uu Ruzhanul Ulum, is a local chief of a large conservative rural district, within West Java, balancing out the urbane University of California at Berkeley-educated mayor.

Opinion polls in February suggested Kamil held a four-point edge over Mizwar, but this was a far cry from the double-digit lead he held in February. While the dip in numbers could be the result of electioneering, the country’s conservatism is also playing a role.

Indonesia’s Widodo vowed to ‘erase stigma’ in Papua. Tell that to the separatists

Conservative commentators regularly complain Kamil’s candidacy amounts to a fifth column for foreign secularism. Matters weren’t helped in February when a Bandung gay rights group declared its support for Kamil. Critics pounced. Others dismissed it as a black campaign – the smears that comprise modern election campaigns here.

But Kamil took the issue head on.

“Once again, the LGBT community has declared its support,” Kamil declared to his 7.7 million followers on Instagram.

“This is not a black campaign. They are free to declare their support for whomever they like. Never call it a black campaign.”

The tactic reflects Kamil’s strength. His social media savvy and his youth, 46, versus Mizwar who turns 63 in March, makes him a more natural fit for the 60 per cent of the electorate who are under 40 in this university town. But his ace in the hole is his track record.

“Kamil has the best chance of winning the election,” says Firman Manan, a political science professor at Bandung’s Padjadjaran University.

“He is seen as a young, visionary leader.”

Rohingya or Afghan? In Indonesia, a tale of two refugee groups

A short stroll though Bandung’s downtown shows how far the city has come. The main downtown street, Jalan Braga, home to restaurants, bars and cafes that cater to foreign tourists is now tree lined, seemingly with more benches and potted plants than in all of the nation’s capital, Jakarta, 100km away. A dozen parks have been renewed including an expanse of gardens and fountains in front of city hall that opened to the public in December.

And while the crosswalks utterly fail to force motorists to yield to pedestrians they nevertheless sport whimsical motifs such as numbers and hatch marks that resemble a ruler or others that resemble a collection of Javanese flutes.

More substantially, a command centre in city hall displays and records live data ranging from birth weights of the city’s newborns to video from 115 CCTV cameras scattered throughout the city. On a recent Monday a drab olive green mini bus was blocking an intersection.

Battleground Malaysia: China extends crackdown on Uygurs across borders

“We’ll watch him for a while and if he doesn’t move we can put in a call to the traffic warden,” says Hiandini, a small bespectacled woman in a pink floral hijab.

“All this data is good for making decisions,” she said waving to the dozen or so large screens in front of her.

Even so, Inna Savova, the author of the “City of Pigs” blog, says she stands by her assessment. Her post, which earned her death threats was widely covered in local media. Littering is still rampant, she says, and conditions quickly deteriorate outside the city centre.

“Everyone…agrees something should be done,” recalls Ms Savova who moved from Bandung to Bulgaria a year ago.

“No one acknowledged they should be the first to change.”

Still, there is no denying conditions have improved. There’s bevy of indexes to that illustrate this, including a happiness index. Started in 2014 at the behest of Kamil, the index measures conditions such as safety, environment, health and leisure. Its inaugural reading was 68.2. Last year it was 73.4.

Sex, pork and jihad: Heard the one about Indonesia’s hijab-wearing Muslim comic?

“When he asked me to come work for him I immediately said ‘yes’,” says Hery Antasari, the head of the city’s planning department.

Mr Antasari, who has known Mr Kamil since high school, says the mayor’s reputation and wide network of contacts help him tap into talent.

“In this election, for us we lose either way. If he loses the election it’s bad. If he wins, it’s bad because we’ll lose him.”