Algiers - Algeria's ailing leader Abdelaziz Bouteflika submitted his resignation with immediate effect, state media said Tuesday, ceding power in the face of massive street protests after two decades at the helm.
Car horns sounded on the streets before crowds of flag-waving people emerged from their homes and converged in the centre of the capital Algiers to celebrate.
Bouteflika "officially advised the Constitutional Council of the end of his term of office as President of the Republic", state television reported.
"I have the honour to formally notify you of my decision to terminate my term of office as President of the Republic from today, Tuesday," state news agency APS quoted his resignation letter as saying.
"This decision which I take in my soul and conscience is destined to contribute to the appeasement of the hearts and minds of my compatriots, to allow them to take Algeria towards a better future to which they legitimately aspire," it added.
Footage showed Bouteflika, dressed in a beige gandoura (North African tunic) and sitting in his wheelchair, handing his resignation letter to the head of the Constitutional Council, Tayeb Belaiz.
Long accused of clinging to power, the veteran leader faced mounting pressure to step down after his decision to seek a fifth term despite rarely being seen in public since suffering a stroke in 2013.
The 82-year-old said last month he would pull out of the bid for another term, and on Monday his office said he would resign before his mandate expires at the end of the month.
The moves failed to satisfy protesters who feared a ploy to extend his rule and the armed forces chief called for him to leave power.
The announcement of his resignation sparked jubilation in the capital.
Youths cheered and waved the Algerian national flag at Grande Post square, the epicentre of the protest against his rule in downtown Algiers, an AFP cameraman reported from the scene.
The United States said the future of Algeria was now up to its people.
"Questions about how to navigate this transition in Algeria, that is for the Algerian people to decide," State Department spokesman Robert Palladino told reporters.
French Foreign Minister Jean-Yves Le Drian said Bouteflika's decision to step down marked the turning of "an important page in the history of Algeria".
"We are confident in the ability of all Algerians to continue this democratic transition in the same spirit of calm and responsibility" that has prevailed in recent weeks, Le Drian added in a statement.
Algeria's constitution says that once the president officially resigns the speaker of the upper house of parliament, 77-year-old Abdelkader Bensalah, acts as interim leader for up to 90 days during which a presidential election must be organised.
The resignation came shortly after the military demanded impeachment proceedings be launched against Bouteflika, responding to Monday's announcement that the president would resign by the end of his term on April 28.
Armed forces chief Ahmed Gaid Salah had called for "the immediate application of the constitutional procedure for removing the head of state from power", in a defence ministry statement after a meeting of top brass.
Without naming anyone, Gaid Salah criticised "the stubbornness, the procrastination and the deviousness of certain individuals who are trying to make the crisis last and make it more complex with the only concern being their narrow personal interests".
He said the army's "sole ambition" was to "protect the people from a handful of (other) people who have unduly taken over the wealth of the Algerian people".
A long-time Bouteflika ally, the general last week called on the president to resign or be declared unfit to rule, becoming one of the first of his faithful supporters to abandon him.
As rumours have swirled of frantic behind-the-scenes manoeuvring, prosecutors on Monday announced they had banned corruption suspects from leaving Algeriaafter launching graft probes against unnamed individuals.
The authorities did not say who was being targeted by probes into corruption and illegal money transfers abroad, but they followed the arrest of the president's key backer, businessman tycoon Ali Haddad.
Haddad, who Forbes magazine describes as one of Algeria's wealthiest entrepreneurs, was detained at the weekend at a border post with neighbouring Tunisia.
Bouteflika had named a new government on Sunday, made up mainly of technocrats under recently appointed premier Noureddine Bedoui.
The administration - supposed to steer the country towards transition - included General Gaid Salah remaining in his position as deputy defence minister.
Among the other key Bouteflika backers is his younger brother and special adviser Said, who was frequently cited in the past as a likely successor to the president.
Discreet and rarely seen in public, Said Bouteflika has exerted increasing influence behind the scenes as his brother's health worsened, but the president's resignation could take away much of his power.