Kenya's president and opposition leader signed a deal to create a power-sharing government on Thursday, hoping to end a post-election crisis that plunged the country into its worst turmoil since independence.

After a month of often bitter negotiations interspersed with violence around the east African country, President Mwai Kibaki and rival Raila Odinga inked an agreement and shook hands to a roar of applause.

We have a deal, mediator Kofi Annan said. Compromise was necessary for the survival of this country ... they kept the future of Kenya always in their sights and reached a common position for the good of the nation.

Kibaki and Odinga were under intense pressure from the international community and Kenya's 36 million people to find a solution to forestall more violence and help restore the country's reputation as a stable, prosperous regional anchor.

Kibaki's disputed re-election in a December 27 vote triggered ethnic clashes that killed at least 1,000 people and forced 300,000 more to flee their homes.

Under the deal, a new prime minister's position will be created for Odinga, who has sought that job since he first helped elect Kibaki in 2002. He claims the president reneged on a deal to give him the job after that vote.

The deal will also give cabinet posts based on each party's strength in parliament and create two deputy prime ministers' jobs, one for each side of the coalition. Odinga's Orange Democratic Movement (ODM) has the largest number of seats.

Later, Kenya will undertake a full review of the constitution, a 45-year-old document which many Kenyans have pushed to change since the 1990s since it gives the president nearly unchecked authority over the affairs of state.

Many Kenyans want a new charter to help address rifts over land, tribe and wealth that have plagued the nation since before independence from Britain in 1963.

'NEW CHAPTER'

Thursday's talks brought Odinga and Kibaki to the same table for the first time in a month, after an exasperated Annan suspended negotiations on Tuesday and said the two leaders had to strike a deal themselves.

As a nation there are more issues that unite than 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, Kibaki said in his speech afterward.

Kibaki ordered parliament to convene next Thursday to pass a constitutional amendment to push through the changes.

A beaming Odinga said after the signing: We have opened a new chapter in our history, from the era of confrontation to the beginning of cooperation.

We should begin to ensure that Kenyans begin to celebrate and love each other, that we destroy the monster that is called ethnicity, he said.

Shortly afterward, riot police fired several canisters of teargas at rowdy Odinga supporters celebrating just near president's downtown office where the signing took place.

In his opposition stronghold Kisumu, on the shores of Lake Victoria in western Kenya, residents took to the streets celebrating and ululating over the deal, witnesses said.

The immediate effect on Kenya's economy was not clear as markets had closed, but the shilling currency had strengthened in anticipation of a deal this week.

The closer you get to a resolution, the better. The question is now the magnitude of the damage done to companies and the economy, said Matthew Pearson, head of African equities research at Renaissance Capital Management in London.

'COMMON SENSE PREVAILS'

The crisis exploded after Kibaki was sworn in on December 30 and Odinga claimed the election was rigged.

Kibaki said he won fairly and blamed his rival for inciting violence and unrest instead of going to court to challenge the result -- the closest in Kenya's post-independence history.

Protests turned into riots and looting sprees met with a forceful police response and simultaneously, ethnic attacks by opposition backers on Kibaki's Kikuyu tribe exploded and later unleashed reprisal killings that left at least 1,000 dead.

The United States, Britain and the European Union applauded the deal, which they had pushed very hard to get finished as quickly as possible.

We are pleased ... It allows the Kenyan people to move forward with a very basic issue of governance, U.S. State Department spokesman Tom Casey said.

British Prime Minister Gordon Brown said common sense has prevailed ... Real leadership, patience and tolerance is necessary to ensure that the agreement sticks.