Opposition leader Morgan Tsvangirai, who had been under heavy pressure from southern African leaders, announced the decision after a meeting of his Movement for Democratic Change’s (MDC) National Council. He is now set to become prime minister.
"Now is the time for us to put aside our political differences, to prioritise the welfare of the people," Tsvangirai said in a statement after the decision in Harare.
It could be a step towards saving the ruined economy of the once prosperous country, where half the people now need food aid and Africa’s deadliest cholera epidemic in 15 years has killed 3,100 people and infected 60,000.
But it is unclear that old foes Mugabe and Tsvangirai will be able to work together effectively to persuade Western states to provide the investment and aid needed by a country with the world’s highest inflation rate and an almost worthless currency.
"Without the support of those governments, the deal will have major difficulties in really opening the way for a turnaround of the situation in Zimbabwe," said Mike Davies, Middle East and Africa expert at risk analysts Eurasia Group.
Zimbabweans have been longing for a new leadership. The few who have jobs line up for hours outside banks to withdraw enough to buy a loaf of bread. Millions have fled to Zimbabwe’s neighbours, straining regional economies.
Some rejoiced after the announcement on Friday.
"I just had to be here to witness history," said Edwin Masango, a city office worker who left his post to join scores of chanting MDC supporters who mobbed Tsvangirai. "I do not remember being this happy and hopeful in a long time."
Shares in Zimbabwe-focused investment group LonZim jumped over 9 percent.
Mugabe and Tsvangirai signed their power-sharing deal in September to end a worsening crisis after elections that were condemned around the world, but implementation had been held up by disagreements over who would get top cabinet positions.
Under pressure from increasingly impatient regional leaders, Tsvangirai agreed at a summit this week to share control of the Home Affairs ministry — responsible for the police — with Mugabe’s ZANU-PF for six months.
The government is set to be formed by February 11.
Tsvangirai said the focus should be on "stabilisation, development, progress and democratization."
Some MDC leaders had felt Tsvangirai was taking a risk by agreeing to work with Mugabe, a master political tactician in power since independence from Britain in 1980, who has defied Western sanctions and resisted growing calls to step down.
"I think that it is a clever and strategic decision. There are, however, challenges facing the MDC," said Adam Habib, political analyst at the University of Johannesburg.
"They have to make sure they can engage in a way that allows them to achieve what they want and that means they have to learn how to engage Mugabe and the people around him," he said.
Daniel Shoko, an unemployed youth, said he was so pleased by the agreement that he had postponed his plan to leave the country, but he remained cautious.
"The MDC will have to be careful as it deals with ZANU-PF. They have to avoid being swallowed up," he said.
Tsvangirai won most votes in a presidential election last March but without enough votes to avoid a run-off. He pulled out of the second round, citing attacks on supporters, and Mugabe was declared the winner unopposed.
Although many countries stand ready to help Zimbabwe, the global financial crisis means there is less money available than there might have been had the deal been reached sooner.
"Some foreign investors did buy into Zimbabwe around the time of the election last year and they have been very dismayed by what has happened since," said Richard Segal, a strategist at UBA Capital.
The last official figure for inflation was 231 million percent, but that was last July. Prices have been doubling every day recently and the government announced on Thursday it would let Zimbabweans use foreign currencies.
South African President Kgalema Motlanthe said his country, the continent’s biggest economy and regional power, was ready to help rebuild its neighbour.
"This stage is really critical in terms of achieving political stability and the first step towards the economic recovery of that country," Motlanthe told Reuters at the World Economic Forum annual meeting in Davos.
South Africa’s government said an inclusive government could prepare for free and fair elections.
But Mugabe’s African critics were sceptical.
"It is the time for Mr. Mugabe to be shown the door. If he is to be given a safe exit…so be it," said Kenyan Prime Minister Raila Odinga, a former opposition leader who agreed to share power after post-election violence last year.