IT HAS been a rough month for Joko Widodo, universally known as Jokowi, the governor of Jakarta who had been expected to stroll to victory in Indonesia’s presidential election on July 9th. First, on April 9th, came a setback in parliamentary polls. His Indonesian Democratic Party of Struggle (PDI-P) won only 19% of the popular vote, a long way short of the 25% that it needed to nominate a presidential candidate on its own. That was followed by opinion polls suggesting his ratings were dropping; one respected survey showed only 51% of respondents now prefer him as president, compared with 62% last December. Then came unusually sharp criticism in the media that he has no vision or policy proposals for the country. Jokowi was still expected to win but the mood of the campaign had changed.

His team set about trying to regain the initiative and on May 14th they scored a success, announcing an alliance with Golkar, the party of Suharto, the late dictator, to form a new coalition with which to contest the presidential election and form a government. Golkar is now the political vehicle of Aburizal Bakrie, a tycoon, and came second in the parliamentary elections with 15% of the vote. Previously, some believed Golkar would support a candidate to run against Jokowi. The PDI-P has also linked up with a new, small party, NasDem, and with an Islamic one, the National Awakening Party. This four-party coalition’s total share of the popular vote would be almost 50%.

Such a coalition would probably be able to govern more effectively than the unwieldy six-party coalition of the outgoing government, headed by President Susilo Bambang Yudhoyono. In ideological terms the four partners are relatively compatible, and having fewer minor parties would make for less legislative wrangling. The coalition could probably command a majority in the 560-seat parliament.

All this is good news for Jokowi ahead of the deadline on May 20th for parties to register their presidential candidates. Now the election is clearly a two-horse race; only Prabowo Subianto, a former general, remains a threat to Jokowi. His Great Indonesia Movement Party, or Gerindra, won 12% of the popular vote on April 9th. The same survey that gave Jokowi 51% in April gave Mr Prabowo 36%, up from 23% last year. Gerindra has the support of two other Islamic parties, but missing out on the support of Golkar will make it harder for Mr Prabowo to pretend that he is offering a workable coalition of his own.

Jokowi has also been spelling out what he would do if he wins. He has promised to scrap fuel subsidies and channel the money that saves to the poor and into infrastructure. His choice of vice-presidential candidate will be important, too. He needs to pick someone with experience to offset his own relative youth. Jusuf Kalla, a 72-year-old former vice-president, is widely tipped. Such an appointment would be the final element to set Jokowi back on track for victory.