Lebanon’s Prime Minister Saad Hariri has said he is resigning, amid protests that have gripped the country for almost two weeks.

Mr Hariri said Lebanon had reached a deadlock and needed a shock to break the crisis.

The announcement was met with cheers from protesters in Beirut.

The protests began against now-scrapped plans to tax WhatsApp calls, but quickly widened to target political corruption and economic turmoil.

Lebanon has one of the highest debt levels in the world.

The protests have led to a 10-day closure of banks, with many other offices, schools and universities also shut.

What did Mr Hariri say?

In a televised address, the prime minister said he had reached a “dead end” and that he would tender his resignation and that of the government to President Michel Aoun.

Mr Hariri said: “For 13 days, the Lebanese people have waited for a decision for a political solution that stops the deterioration. And I have tried, during this period, to find a way out, through which to listen to the voice of the people.”

But he added: “It has become necessary for us to make a great shock to fix the crisis.

“Posts come and go, what matters is the safety and dignity of the people.”

President Aoun is still to comment. If the resignation is accepted, the constitution would require Mr Hariri to stay on until a new administration is established.

What is the state of the protests?

The prime minister’s announcement came as the situation on the ground turned increasingly violent, reflecting the deep-seated schism in Lebanese society.

The militant Shia group, Hezbollah, which has dominated the coalition government led by Mr Hariri, a Sunni, has recently hardened its stance against the protests.

On Tuesday, black-clad men loyal to Hezbollah and another Shia group, Amal, ransacked a protest camp in central Beirut, chanting slogans, setting tents on fire and beating anti-government demonstrators. A roadblock set up by protesters was also attacked.

Riot police and troops fired tear gas to separate the rival groups.

The protesters remained defiant in central Beirut. Less than an hour after being attacked they erupted into applause at the announcement of Mr Hariri’s resignation.

One demonstrator, Tima Samir, told Agence France-Presse: “This resignation is welcome but it is not enough… We want the entire system to change and we’ll stay on the streets until all our demands are met.”

How did we get to this point?

The crisis began on 17 October when the government announced a new daily tax for calls made via voice-over-internet-protocol (Voip), which is used by apps including WhatsApp, Facebook Messenger and Apple’s FaceTime.

The government backtracked within hours but the protests were soon underway and quickly burgeoned.

As one demonstrator said: “We are not here over the WhatsApp, we are here over everything: over fuel, food, bread, over everything.”

Last week, Mr Hariri and his coalition, including Hezbollah, agreed to a plan of reforms to try to placate protesters, but their campaign continued.

On Friday, Hezbollah’s leader, Hassan Nasrallah, said “someone is trying to pull [Lebanon]… towards civil war”, suggesting the protests were funded by foreign powers and indicating a harsher policy towards the protesters.

Hezbollah had argued against Mr Hariri’s resignation, saying it could result in a void in the Lebanese government.

The BBC’s Martin Patience says many in the population are tired of economic stagnation, endemic corruption and a lack of basic public services.

He adds that the developments will alarm the West, which regards Lebanon as an island of relative stability in the turbulent Middle East.

The power-sharing agreement that ended the country’s civil war 30 years ago has kept the peace, but it has failed to halt the slide towards economic crisis.