Romanian prime minister Victor Ponta has announced the resignation of his government after huge protests in the wake of a nightclub fire that killed more than 30 people.

"I'm handing in my mandate, I'm resigning, and implicitly my government too," Mr Ponta said. He added he would stay on until a new government is in place.

"I am obliged to take note of the legitimate grievances which exist in society," said Mr Ponta. "I hope handing in my and my government's mandate will satisfy the demands of protesters."

President Klaus Iohannis will name a prime minister to form a new government, which needs to be approved by parliament. If this fails twice, early elections will be called. Romania is scheduled to hold parliamentary elections in December 2016.

Deputy leader of the opposition Liberal Party, Catalin Predoiu, hailed the resignations. "This is a victory of the street. It is a lesson for all politicians," he said.

Some 20,000 people took to the streets of Bucharest on Tuesday evening in a spontaneous protest calling for the resignation of Mr Ponta, interior minister Gabriel Oprea and a district mayor where the Colectiv nightclub was located.

They shouted "Shame on you!" and "Assassins!" and waved Romanian flags. Anger has been brewing for some time in Romania against the government, which many perceive as being corrupt, and Friday's fire has added to the discontent.

Witnesses said the fire broke out during a heavy-metal concert in the basement club when a spark ignited foam decor, sending panicked people stampeding for the single exit.

The death toll stands at 32, with some 130 still in hospital, dozens of them in serious or critical condition.

The mayor of the district in the Romanian capital where the nightclub was located has resigned, saying he was morally guilty for the deadliest fire in Romania's history.

Cristian Popescu Piedone said: "I assume the moral blame. As for the legal (blame), I will leave it to justice to pronounce."

The main opposition party has called for early elections after the resignations.

Alina Gorghiu, co-leader of the Liberal Party, said her party wants elections "to resolve the crisis we find ourselves in". However, she said she wanted a broad political agreement with other parties for the proposal.