He said he would stand down at a date to be determined by Parliament, which will convene in the coming days to select an interim president to serve until next year's elections.
National Assembly speaker Baleka Mbete, who is also chairwoman of the African National Congress, is widely tipped to become the interim head of state, paving the way for Mbeki's nemesis, Jacob Zuma, to take over after the elections.
The ANC has a huge majority and is expected to romp to victory in the polls despite its upheavals.
"I am convinced that the incoming administration will better the work done during the past 14-and-half years so that poverty, underdevelopment, unemployment, illiteracy, challenges of health, crime and corruption will cease to define the lives of many of our people," Mbeki said.
Mbeki, 66, lost the final battle in the long struggle against ANC President Zuma, his former deputy, on Saturday. Mbeki was pressured to quit after a judge threw out a corruption case against Zuma earlier this month on a legal technicality and implied that Mbeki's administration had put political pressure on prosecutors.
In his television address, Mbeki said "categorically" that he had never interfered in the work of prosecutors. He said that included "the painful matter" of the Zuma case. Zuma has been under a cloud for the past eight years from allegations relating to a big arms deal.
A senior ANC official, Matthews Phosa, said the party had asked the Cabinet to remain on the job.
"We want the Cabinet to stay," Phosa said. "We want stability and we want them to stay ... but we cannot enforce things upon them," he said on South African television.
Early indications were that most Cabinet ministers had agreed to stay, including Finance Minister Trevor Manuel, who is important to investor confidence in South Africa.
Phosa also said the party wanted Mbeki to continue as mediator in Zimbabwe, where he recently persuaded President Robert Mugabe to share power with the opposition.
Although increasingly isolated at home in recent months, Mbeki persisted in his statesmanship abroad. In his speech he reeled off a list of countries that have benefited from South African mediation and quiet diplomacy: Congo, Burundi, Ivory Coast, Sudan and Zimbabwe.
"These African patriots know as I do that Africa and Africans will not and must not be the wretched of the earth in perpetuity," Mbeki said.
Despite the humiliation inflicted on him by the party to which he has belonged for the past 52 years - and despite his own reputation for dealing ruthlessly with opponents - Mbeki was graceful in defeat. He did not fill his speech with recriminations, as some had feared.
He thanked South Africans for letting him serve them - for five years as deputy president and nine years as president.
He likened public office to a marathon of long roads, steep hills, loneliness and uncertain rewards at the end and urged South Africans to cherish the freedoms gained by many years of anti-apartheid struggle.
"We should never be despondent if the weather is bad, nor should we turn triumphant because the sun shines," he said.
He traced the achievements of his office, including transforming the economy "resulting in the longest period of sustained economic growth in the history of our country," spurring social progress and winning the right to host the 2010 World Cup.
"Despite the economic advances we have made, I would be first to say that ... the fruits of these positive results are still not fully and equally shared among our people, hence abject poverty coexisting side by side with extraordinary opulence."
He said much more needed to be done to combat the "twin challenges of crime and corruption."
Mbeki had been on the losing end of a power-struggle to Zuma for months. He lost his bid for a third term as ANC president to Zuma at the party congress last December and the knives had been out for him ever since.
Mbeki fired Zuma as national deputy president in 2005, after Zuma's financial adviser Schabir Shaik was convicted of trying to solicit a bribe to deflect investigations into the arms deal.
Initial charges against Zuma were withdrawn, but the chief prosecutor said last December that he had enough evidence to bring new ones. That was within days of Zuma being elected ANC chief.
Judge Chris Nicholson threw out the new charges last week on a technicality and implied they were the result of political interference.
But he made no pronouncement on Zuma's guilt or innocence.
Nicholson's verdict gave Mbeki opponents the ammunition they needed.
Democratic Alliance leader Helen Zille said even opposition parties were stunned at the suddenness of Mbeki's ouster.
"The vicious way in which Mbeki was forced out by his enemies has shocked the nation," she said.
Zille said Mbeki leaves a "checkered legacy" because of his refusal to accept the causes and seriousness of the AIDS epidemic, which now kills more than 900 South Africans per day, and his refusal to criticize Mugage.
"His denialism of HIV/Aids and crime cost thousands of lives; he undermined his own vision of an African renaissance by siding with despots on the continent," Zille said. "He has left South Africa more divided than when he assumed office."