Thousands of people have marched through the Romanian capital and other cities to protest against a government proposal to pardon thousands of prisoners, which critics say could reverse the anti-corruption fight.

More than 10,000 protesters gathered on Sunday in University Square in Bucharest, and later broke through police lines, before heading toward government headquarters. Thousands also protested in the western city of Cluj and in Iași in the north.

Elderly people were among the protesters, with others carrying carried children on their shoulders or holding them in their arms. Demonstrators called the ruling Social Democratic party “the red plague”.

In Bucharest, protesters shouted: “We want democracy, with thieves in prison.” They cheered after the president, Klaus Iohannis, a government critic who supports the anti-corruption drive, turned up at the protest.

Klaus Iohannis joins the protest in Bucharest. Photograph: Inquam Photos/Reuters

Iohannis said: “A gang of politicians who have problems with the law want to change the legislation and weaken the state of law … Romanians are rightly indignant.”

The prime minister, Sorin Grindeanu, wants to pass an emergency ordinance to pardon prisoners, which his government says would ease overcrowding in prisons. But critics say it would help government allies convicted of corruption. They also say the proposal should be debated in parliament.

Donald Simionoiu, an art director, said he believed the proposal “hides other things”, noting that it would benefit Liviu Dragnea – the Social Democratic party chairman who was given a two-year suspended prison sentence for vote rigging – and the media mogul Dan Voiculescu, who is serving a 10-year sentence for money laundering.

On Wednesday, the justice ministry published a draft of the plan, which was criticised by Romania’s top prosecutor, magistrates and opposition politicians. The proposal could primarily affect those with sentences under five years, except those convicted of crimes of a sexual nature, violence or corruption.

Prisoners over 60, pregnant women and people with young children would see their sentences halved regardless of their convictions.

Prison authorities say 3,700 prisoners could be freed. The government said about 2,500 would be freed.