Jacob Zuma, the president of South Africa, has resigned after days of defying orders from the ruling African National Congress to leave office and on the eve of a no-confidence vote in parliament.
In a televised address to the nation late on Wednesday, the 75-year-old said he was a disciplined member of the ANC, to which he had dedicated his life.
I fear no motion of no confidence or impeachment I will continue to serve the people of South Africa and the ANC. I will dedicate my life to continuing to work for the execution of the policies of our organisation, Zuma said.
No life should be lost in my name. The ANC should never been divided in my name. I have therefore come to the decision to resign as president of the republic with immediate effect.
At noon, ANC officials announced they would vote for an opposition partys no-confidence motion in parliament on Thursday.
Late in the afternoon, Zuma gave an angry and rambling TV interview to justify his refusal to obey his own partys order to step down.
But his speech was more confident and warm.
The president started with a joke with journalists about the late hour, and his trademark chuckle. He expressed his gratitude to the ANC and South Africans for the privilege of serving them at the pinnacle of public life, before saying thank you and goodbye in three local languages.
Zumas resignation leaves the path clear for deputy president, Cyril Ramaphosa, who took over the leadership of the ANC in December, to be elected by parliament to the highest office.
Zuma, a former anti-apartheid activist who has led the ANC since 2007 and been South Africas president since 2009, was due to leave power next year.
His tenure has been marred by economic decline and multiple charges of graft that have undermined the image and legitimacy of the party that led South Africans to freedom in 1994.
The chaotic political crisis of recent days has further damaged the ANC, and angered many South Africans who are increasingly impatient with the partys opaque internal procedures.
Ramaphosa won a bitterly fought internal election in December and is seen as the standard bearer of the partys reformist wing.
Party strategists wanted Zuma to be sidelined as quickly as possible to allow the ANC to regroup before campaigning starts for elections in 2019.
The party suffered significant setbacks at municipal polls in 2016 and could be forced into a coalition government at the national level, experts say.
As president, Ramaphosa will have to balance the need to reassure foreign investors and local businesses against the intense popular demand for dramatic measures to address South Africas deep problems.
The 65-year-old former trade union leader has said South Africa is coming out of a period of uncertainty, a period of darkness, and getting into a new phase.
Richard Calland, an expert in South African politics at the University of Cape Town, said the departure of Zuma from office would give Ramaphosa the chance to rebuild government and the party at the same time.
In recent days, the rand has strengthened and many analysts have revised upwards their predictions of South Africas economic growth.
Following Zumas address on Wednesday night, the ANC immediately closed ranks.
Jessy Duarte, the partys deputy secretary general, told reporters that the ANC was not celebrating at a very painful moment.
Duarte said: Having taken the difficult decision to recall Comrade Zuma, the ANC nonetheless salutes the outstanding contribution he has made and expresses its profound gratitude to him for the role he has played in the ANC over 60 years of loyal service.
Neeshan Balton, the executive director of the Ahmed Kathrada foundation, an NGO dedicated to the values of the freedom struggle, said Zumas resignation would be greeted by a sigh of relief from all South Africans.
He said: For the first time in almost a decade, South Africans can rejoice that the sun has set on the Zuma era. We can finally celebrate that the president, who had become a symbol of the erosion of state integrity, has left office.