Kenya's parliament has approved an amendment to the constitution and a new law to allow the country's first-ever power-sharing coalition.
It is hoped the deal will end the deadly political rivalry that has left more than 1,000 people dead since presidential elections in December.
Violence erupted after the two main parties claimed victory.
After approving the constitutional changes, legislators extended the session to debate the final step in the deal; a law which will allow Raila Odinga, the opposition leader, to take the newly created post of prime minister, so sharing power with President Mwai Kibaki.
The Constitution of Kenya (Amendment) Bill was passed by a unanimous 200-0 majority in a session broadcast live on television.
The amendment creates the positions of a prime minister and two deputies in the cabinet; it needed a two-thirds majority.
The next step was to pass a new law creating these posts in a new unity government, and set out the terms for power sharing in the cabinet.
Both of the measures will still require presidential assent before they become law.
Odinga's party and Kibaki's coalition will each name a deputy prime minister, while the cabinet will be split evenly between both sides to form a unity government.
However no indication has been given as to when that will happen.
As well as restoring stability and getting the economy back on track, the new administration must also come up with plans for a long term constitutional solution to Kenya's problems.
The violence laid bare underlying political issues of power, inequality, tribal feuds and land ownership.
The crisis began after Odinga accused Kibaki of stealing the election in December, but the violence also opened up tribal rifts going back many decades.
As well as more than 1,000 people dead, the fighting left at least 300,000 more homeless.
In a speech to legislators on Thursday, President Kibaki urged them to set aside partisanship and enshrine into law a pact to end the post-election crisis.
Kibaki, who will remain president, gave the speech as he chaired a meeting of the Grand Coalition Joint Parliamentary Group before officially opening the parliament session.
"I urge all honourable members to support the proposed legislative measures which will go a long way in ensuring peace and stability in our country," he said.
"I also appeal to you all, to be guided by a strong sense of national unity, which must override all partisan considerations."
The agreement between Kibaki and Odinga was reached after weeks of mediation by Kofi Annan, the former UN secretary-general.
Both sides have agreed to set up a committee that will outline policies for the coalition government to be formed in the near future.
The newly formed cabinet coalition will replace the previous government announced by Kibaki, days after he was controversially declared the winner of the presidential polls.
Last month's accord had been well received in Kenya but tough negotiations lie ahead for both sides as the government line-up remains yet to be decided.