Mwai Kibaki, the president, and Raila Odinga, the top opposition leader, sat down at a desk in front of the president's office, with a bank of television cameras rolling, and signed an agreement that creates a powerful prime minister position for Odinga and splits cabinet posts between the government and the opposition.
The two sides, which have been bitterly at odds for the past two months, will now be fused together in a government of national unity.
But there are still many issues to resolve, starting with how the new government will function with essentially two leaders who have tried unsuccessfully to work together before. The government must also deal with the delicate business of reassigning the choice positions already given to Kibaki's allies.
There is also a deeply divided country to heal. More than 1,000 Kenyans have been killed and hundreds of thousands driven from their homes in an uncharacteristic burst of violence set off by a deeply flawed election in December. Much of the fighting, like the voting, has been along ethnic lines.
Kenya used to be considered one of the most prosperous and stable nations in Africa, known as an oasis of peace in a turbulent region.
The violence has cooled down in the past few weeks, but the tension and displacements have continued. Many Kenyans have said that the country will not return to peace until the dueling politicians agree to some sort of solution.
Annan took the lead in trying to bring the two sides together. For the past month, he has been meeting nearly every day with negotiators for Kibaki and Odinga, searching for a political compromise. More than anyone else, Annan has been the hope of this country. A baby rhino recently born in one of Kenya's fabled game parks was even named after him.
But earlier this week, Annan seemed to have run into a brick wall. Negotiators deadlocked over whether they would share responsibilities or share power, with the government refusing to give Odinga substantial authority or to amend the Constitution to create the position of prime minister. Annan then decided to bypass the negotiation teams and go directly to Odinga and Kibaki. He met with them behind closed doors for more than four hours on Thursday.
At 4:30 p.m. local time, Annan, Kibaki and Odinga emerged. The two leaders signed the agreement with Annan standing behind them, his hands clasped, as a crowd of diplomats, cabinet ministers and political supporters clapped.
Under the deal, the party that holds a majority in Parliament — currently Odinga's — will elect a prime minister to "coordinate and supervise" government affairs. The cabinet positions will be divided, based on parliamentary strength. Parliament will pass an act and a constitutional amendment guaranteeing all this.
Annan said the deal was Kenya's only way out of the crisis.
"Today we have reached an important staging post, but the journey is far from over," Annan said. "Let the spirit of healing begin today. Let it begin now."