Kenyan President Mwai Kibaki and opposition leader Raila Odinga have signed an agreement to end the country's post-election crisis.
At a ceremony in Nairobi, the two men put their signatures to a power-sharing deal brokered by ex-UN head Kofi Annan.
A coalition government comprising members of the current ruling party and opposition will now be formed.
Some 1,500 people died in political violence after Mr Odinga said he was robbed of victory in December's polls.
International observers agreed that December's election count was flawed.
The post-election violence saw thousands of people targeted because they belonged to ethnic groups seen as either pro-government or pro-opposition. About 600,000 people fled their homes.
Although the level of violence had fallen in recent weeks, there were concerns that a failure to reach a deal would lead to a fresh round of blood-letting.
Negotiations between the government and opposition lasted more than a month, stalling several times.
The BBC's Adam Mynott, in Nairobi, says both sides have given ground
from their original positions to reach this agreement.
The new coalition will be headed by President Kibaki, with Mr Odinga - whose Orange Democratic Movement (ODM) is the largest in parliament - probably taking the newly created post of prime minister.
Each party will nominate a deputy prime minister, with other ministerial portfolios being shared out to reflect the political
parties' strengths in the National Assembly.
Correspondents say both parties are now likely to begin wrangling over who gets what position in the new government, with the post of finance minister likely to prove the most contentious.
After the deal was reached, Mr Annan said: "Compromise was necessary for the survival of this country."
He urged all Kenyans to support the agreement, saying: "The job of national reconciliation and national reconstruction is not for the leaders alone. It must be carried out in every neighbourhood, village, hamlet of the nation.
"I call on all Kenyans to support this process so that Kenya can once again be a moral inspiration and economic engine for Africa. And let me assure you that your friends in Africa and the international
community are all behind you."
Speaking after the signing, Mr Kibaki said: "This process has reminded us that as a nation there are more issues that unite than that divide us...
"We've been reminded we must do all in our power to safeguard the peace that is the foundation of our national unity... Kenya has room for all of us."
“The agreement opened a new chapter in our country's history - from the era or phase of confrontation to the beginning of co-operation.
"We, on our side, are completely committed to ensuring that this agreement will succeed."
Both men thanked those who had stood by Kenya in what Mr Odinga called its "hour of need", including Mr Annan, the African Union, the European Union, the United States and the UN.
They also urged Kenyans to move forward together without ethnic divisions.
A spokesman for the US state department, Tom Casey, said the agreement was "an important and very positive step forward".
He added: "It allows the Kenyan people to move forward with a very basic issue of governance."
British Prime Minister Gordon Brown welcomed the new power-sharing agreement.
"Kenya's leaders have reached a power-sharing agreement that represents a triumph for peace and diplomacy, and a renunciation of the violence that has scarred a country of such enormous potential," he said.