After weeks of rancorous negotiations to resolve a postelection conflict that killed nearly 1,500 people, Kenya's two rival parties signed an agreement on power-sharing Thursday.

Under the agreement, President Mwai Kibaki will retain the position of president, although international observers and Kenya's own election commission have declared his election deeply flawed. Opposition leader Raila Odinga will become prime minister, although his powers are decidedly ceremonial.

The pact does not address such key issues as a new Con-stitution, land redistribution, and human rights violations. But with it, Kenya appears to be turning the corner toward a tentative peace. Now begins the work of making politicians set aside rivalries and greed to form a unity government and to urge ethnic communities that have massacred each other to make amends.

"We believe by these steps we come together in the spirit of partnership to bring peace and prosperity to the people of Kenya who so richly deserve it," said a visibly relieved Kofi Annan, the former UN secretary-general, who led the four-week-long mediation effort in Nairobi.

He urged hard-liners on both sides to accept the agreement. "To those people in Kenya I would say this: Compromise was necessary for the survival of this country. Support this agreement for it is the key to unity of Kenya."

Under the deal, the president and prime minister will each nominate one deputy prime minister. The prime minister and the deputies can be removed only if parliament casts a vote of no confidence. The cabinet will be based on parties' representation in parliament. The agreement must be ratified by parliament, which Kibaki has ordered to meet on March 6 to start reviewing the accord.

Reaction in the streets of Nairobi was first one of relief, and in some places, elation. "We thought there would be more antagonism, more chaos, but I think the deal happened today because people are tired," says Ole Surum, a youth leader for the Youth Employment Network in the slum of Kibera. "People are not supposed to fight one another. If this deal didn't happen, there would have been a disaster."

Despite its weaknesses, the power-sharing pact is a step forward, especially after nearly two months of violence that displaced 300,000 and left East Africa's driving economic force in tatters.

"This crisis was over power, so now that they have agreed to share power, it's over," says Ahmed Nasir Abdullah, a political analyst in Nairobi and former head of the Law Society of Kenya.

While Mr. Abdullah says that the deal is still more favorable to the president, since the powers of the prime minister are merely to "supervise and coordinate" the cabinet, he says that both sides are likely to hew to the current deal now. "I think that basically with the way the power-sharing agreement was formed on the way forward – in dealing with human rights and the need to reform the Constitution – both partners are intending to go about this on the same wavelength."

Kenya's political crisis began Dec. 27, after a deeply flawed presidential election gave Mwai Kibaki the presidency. But the roots of the conflict go back much further, to the early days of Kenya's liberation from British colonial rule. Longstanding resentment over politicians giving land and contracts to their ethnic groups and families, and the charges of opposition politicians who said that President Kibaki would continue that tradition with a second term, were just the spark to set off a firestorm of violence and ethnic hate.

The power-sharing agreement may be the crucial starting point toward peace, but it is perhaps the easiest step. Many analysts anticipate greater difficulty in the days ahead, as the new Kenyan government of national unity takes up the more contentious issues, such as rewriting the Kenyan constitution, balancing the distribution of wealth and land ownership, reining in politically connected militias, and punishing those persons who have instigated or promoted ethnic violence.

"The danger here is that people will say we have an agreement, so let's carry on with our lives," says Jacqueline Klopp, a political scientist and Kenya expert at Columbia University. "The politicians have their agreement, but their militias and their supporters have not demobilized. Until we have some peace-building, some recognition that what we did was wrong, people are not going to just start going back to Eldoret."

The town of Eldoret, in the Rift Valley, was the site of some of the most horrific violence of the conflict, including the burning of a church that was sheltering ethnic Kikuyu villagers from the armed crowds of Kalenjin neighbors. During the election, most Kenyans voted along ethnic lines, with Kikuyus supporting their fellow tribesman, Kibaki, and ethnic Luos, Kalenjins, and others supporting opposition leader Mr. Odinga.

François Grignon, Africa director of the International Crisis Group, says the agreement was an important step forward and would help ease tension in the Rift Valley. But he warned that there it would take a lot more work to heal Kenya's ethnic and social divisions.

"The implementation of all the agreements is the key issue," he says. "Consultation with community leaders to craft a realistic process of reconciliation is going to be very important."

In some ways, the fact that Kenya's deal took so much effort and time to hammer out is a testament to how much power the international community – including the United Nations – can have.

"Kenya was so close to dissolving," says Ms. Klopp. "That very fact shows how the concerted effort, the real support of the international community, can make a difference. We can never say again that there is nothing to be done."

• Freelance reporter Muchiri Kioi contributed to this story from Nairobi.