Fears have been raised for Indonesia’s democracy after its parliament voted to abolish the direct election of local leaders, a key post-dictatorship reform credited with assisting president-elect Joko Widodo’s rise to popularity as a mayor and governor before he won July’s national election.

The legislation – passed in the early hours of Friday after intensive lobbying – will mean provincial governors, district chiefs and mayors will now be elected by legislative bodies rather than directly by the people.

It could also lead to Widodo’s opponents in the incoming parliament – in which his coalition will hold just over a third of the seats – using its appointees to block his reforms at the local level.

Direct elections, part of the decentralisation measures implemented after the fall of dictator Suharto in 1998, have been credited with producing a handful of promising new leaders unconnected to the old elite, including Widodo, who beat a former general in the election in July.

After the tightest elections in the nation’s history ran peacefully, the world’s third-largest democracy was lauded for it political maturity and held up as an example in the region.

Raised in a riverside slum in Central Java, Widodo, known in Indonesia as Jokowi, is the first elected president with no direct ties to the old political and military establishment.

“The bill is a setback. A step back to a process of electing political leaders that is now in the hands of political parties,” said Djayadi Hanan, a political analyst from Paramadina University in Jakarta. “It is like a comeback for the political oligarchy.”

Doing away with direct elections, say analysts, will stymie the emergence of a new breed of accountable, responsible leaders and entrench the old elite.

Citing a recent poll by the Indonesian Survey Circle that showed more than 80% of Indonesians opposed the bill, Hanan argued that Indonesia’s political elites were trying to tighten their loosening grip on power and in doing so acted “against the will of the people”.

The bill has also been seen as attempt to even political scores, rushed through by an outgoing parliament and passed by a coalition of parties led by Prabowo Subianto, the former general who lost the July election to Jokowi.

“[The Prabowo coalition] want to humiliate Jokowi in the parliament, and this is the first battle,” said Eva K Sundari, a legislator from Jokowi’s Democratic party of Struggle

The ruling coalition in the incoming parliament will account for just over 36% of the seats and unless Jokowi manages to secure the support of another political party, he looks set to face a belligerent parliament after his inauguration on 20 October.

Analysts say that while he might hold power at the top, the opposition could further derail his programmes at a local level following the elimination of direct elections. More than 200 new local leaders, including 11 new provincial governors, are scheduled to be appointed next year and the new bill could help consolidate power in the hands of Jokowi’s opponents.

Aleksius Jemadu, the dean of political sciences at Pelita Harapan University in Jakarta, said the bill reflected an unsavoury new development in Indonesian democracy, one where the parliament “can do anything they want now because they control the majority and no one can stop them”.

In the lead-up to the boisterous 12 hours of debate and lobbying that preceded the vote, it appeared the bill was likely to be quashed. But the party that held the crucial swing vote, outgoing president Yudhoyono’s Democratic party, reversed its position at the 11th hour, walking out of the plenary session and abstaining from the subsequent vote.

That decision cost Jokowi’s coalition more than 100 votes and sealed an easy victory for the Prabowo-led coalition by 226 votes to 135.

Civil society groups and NGOs have vowed to challenge the new law at the constitutional court, but it is unclear whether they could win. Depending on the interpretation of the law, both direct and indirect elections are arguably constitutional.

As Prabowo’s Gerindra party hailed victory, critics on social networks described the bill as the death of democracy and directed their anger towards Yudhoyono under the Twitter hashtag #ShameOnYouSBY.

At a press conference on Thursday evening in Washington, where he was on an official visit, Yudhoyono expressed his regret at the vote. He said his party was preparing a lawsuit to challenge the bill and would seek recourse at the constitutional or supreme court.

Not all political observers are convinced he is sincere, given Yudhoyono could have thrown out the draft law to begin with.

“This reflects the real face of President Yudhoyono’s commitment to develop a genuine democracy,” argued political observer Aleksius Jemadu, “The president was in a position to stop all this in the first place, but he didn’t.”

Widodo has vowed to fight against the law and on Friday said the Indonesian public should remember which “political parties have robbed them of their political rights”.