Zimbabwean President Robert Mugabe has signed a historic power-sharing deal with his long-time rival, opposition leader Morgan Tsvangirai.
The two smiled and shook hands at the ceremony in the capital, Harare, attended by African dignitaries.
Mr Tsvangirai said the agreement provided the best hope for Zimbabwe and called on President Mugabe to work together to implement the deal.
Mr Mugabe said he was committed to national unity and would do "his best".
Mr Mugabe, Mr Tsvangirai and Arthur Mutambara - leader of a breakaway faction of Mr Tsvangirai's Movement for Democratic Change (MDC) - signed the agreement in front of some 3,000 invited guests in Harare's International Conference Centre.
The signatories were introduced in the terms used in the agreement - Mr Mugabe as president and Mr Tsvangirai as prime minister.
To rapturous applause, the leaders shook hands after exchanging signed copies of the accord.
Mr Mugabe accused a former colonial power - Britain - of meddling in his country's affairs by calling for a "regime change" and by imposing sanctions.
He received loud jeers when he said opposition parties in Zimbabwe and other African nations used violence in order to achieve power.
He said there were "lots of things" in the deal that neither leader liked but that they would work together to "find our way".
"As long as salient principles are recognised, there will be room for more agreement," Mr Mugabe said.
In his speech, Mr Tsvangirai said the agreement was a "product of painful compromises" and that it did not provide "an instant cure" to the fortunes of Zimbabwe.
"I've signed this agreement because I believe it represents the best opportunity for us to build a peaceful and prosperous democratic Zimbabwe," he said.
His hope for the future was stronger than the grief felt for "the needless suffering of the past years", he said.
In a gesture of reconciliation, Mr Tsvangirai quoted a speech on reconciliation made by Mr Mugabe in 1980, saying "it is time to turn our swords into ploughshares".
Mr Tsvangirai called for the support of the international community and African neighbours in helping to rebuild the country - healthcare, education and economy.
The new Deputy Prime Minister, Mr Mutambara, said the compromise agreement was a victory for Zimbabwe.
The BBC's George Alagiah in Harare says that the mood among ordinary Zimbabweans is one of relief rather than outright jubilation. People just want to get on with their lives.
The full details and content of the deal have not been confirmed but it proposes a 50-50 division of power, with Mr Mugabe remaining head of state and head of the cabinet.
Morgan Tsvangarai will head a council of ministers, which will be responsible for the day-to-day managing of the country's affairs.
The MDC and its breakaway faction are expected to have 16 ministers, while President Mugabe's Zanu-PF party will have 15 ministers.
The BBC's Adam Mynott says the eyes of Zimbabwe's neighbours, Africa and the whole world will be fixed now on seeing whether this deal does result in a genuine sharing of executive authority.
Negotiations started at the end of July, with a breakthrough coming late on Thursday after difficult negotiations mediated by South African President Thabo Mbeki.
Some MDC members have called it a climb-down, although others have said it is the best available.
David Coltart, an MP from the smaller MDC faction, said on Friday that most MDC members who are due to become ministers "have at some stage in the last nine years been brutalised on the instructions of those they will now have to work with".
The MDC accuses the army and Zanu-PF of organising a campaign of violence against opposition activists to ensure victory in the June presidential run-off.
"Zimbabwe remains highly polarised and it will take statesmanship on all sides to make this work," he said in an e-mail to his supporters.
'A new page'
The deal opens the way for international donors to help to revive Zimbabwe's economy, where inflation is at more than 11,000,000%.
EU foreign policy chief Javier Solana said a decision on lifting sanctions on Zimbabwean officials had been postponed until October.
Mr Solana said the EU needed to study the details of the power-sharing agreement but that he expected it to open "a new page" for Zimbabwe.
The UK was ready "in principle" to support the new unity government but its backing depended on actions on the ground, said Prime Minister Gordon Brown's spokesman.
Mr Mugabe, in power since independence from Britain in 1980, won a controversial presidential run-off election in June.
He ran unopposed after Mr Tsvangirai withdrew, claiming the MDC was the target of state-sponsored violence.
In the first round of the presidential election in March, Mr Tsvangirai gained more votes than Mr Mugabe but official results say he did not pass the 50% threshold for outright victory.
6 months ago