Six weeks of largely peaceful anti-government protests in Bulgaria turned violent on Wednesday when demonstrators laid siege to parliament, threw stones and clashed with police evacuating the building.

For more than 40 days, thousands of mainly young middle-class protesters in the capital Sofia have been venting their disgust with a political class seen as corrupt and ineffectual and demanding the resignation of a government only months old.

Parliament in Sofia remained closed and under heavy police guard on Wednesday, following hours of siege by demonstrators who tore up pavements to build barricades blocking all the exits from the building.

Around 100 MPs and parliamentary staff were trapped inside until police intervened to evacuate them on buses around 3am. Some 20 were injured in clashes.

"Police reacted very adequately, policemen did their job perfectly although protesters behaved extremely aggressively," said the interior minister, Tsvetlin Yovchev.

The European Commission, however, supported the protesters against the EU member state's government. Visiting Sofia, the justice and human rights commissioner, Viviane Reding, said her sympathy lay with demonstrators who were fed up with Bulgaria's pervasive corruption and cronyism.

The protests have been part of an unusual wave of street campaigning that has shaken the paternalistic establishment across the Balkans, with tens of thousands challenging the government of Turkey in the centre of Istanbul and a public rebellion in the Bosnian capital Sarajevo fuelled by frustration at a bickering elite paralysed and rarely capable of taking any decisions.

The collapse of Bulgaria's government in February following protests against rising energy bills led to early elections in May that produced a socialist-backed coalition under Plamen Oresharski, who is now refusing to resign as prime minister.

The latest protests took off last month when he appointed the prominent media mogul Delyan Peevski to the key post of head of national security. This was seen as symptomatic of the nepotism of Bulgarian politics and triggered the street activism, which has been organised on social media just like the campaigns in Istanbul and Sarajevo.

Peevski was fired, but the protests grew, taking fire at the political "mafia" and demanding the fall of the government.

All the signs on Wednesday were that there may need to be another early election. The president, Rosen Plevneliev, said he could call elections while proposing another caretaker government. "We've had three governments so far this year," he told the Wall Street Journal. "Maybe we'll have five. If this government resigns, I'll appoint a new caretaker government."

The protests in Istanbul, Sofia and Sarajevo have displayed novel features – the unusual mobilisation of young articulate urban middle-class people not previously noted for their political activism, but fed up with governments seen as high-handed and out of touch. But the response of the governments has varied greatly.

The clashes between police and stonethrowing protesters in Sofia in the early hours of Wednesday was the worst violence since the protests began. By contrast the Turkish government has resorted to weeks of indiscriminate use of tear gas and water cannon on peaceful demonstrators, leaving five dead and scores seriously injured.

In Sarajevo, too, the protests have been allowed to take place without heavy-handed police intervention.

The Balkan campaigns have all been triggered by relatively small, local issues but have then mushroomed into broader insurrections against governments and prime ministers.

In Bosnia the demonstrations were triggered by the inability of lawmakers to agree on a new system of ID numbers for citizens, paralysing bureaucratic procedure and meaning that newborn babies could not get passports, social security benefits or health care.

The educated of Sarajevo blockaded the parliament, with many young mothers with children in pushchairs joining in to vent their disgust at politicians seen as incapable of agreeing anything except to further their own interests.

In Turkey the protests were ignited by a high-handed government decision to demolish a park in central Istanbul to make way for a kitsch replica of an old military barracks along with a new shopping mall.

The project was personally pushed by the prime minister, Recep Tayyip Erdogan, whose brutal response to the challenge to his authority has damaged his international image and his standing at home after a decade of utterly dominating Turkish politics.

Bulgaria's coalition government is led by the Socialists, who only commands half the legislature, 120 of 240 seats. By contrast the Sofia protests appear to enjoy wide public support, with polls showing two-thirds backing for the demonstrators.