"I, Raila Amolo Odinga, do swear that I will be faithful to the president of the Republic of Kenya and to serve it with all my heart and that I shall preserve, protect and defend the constitution of Kenya by law established. So help me God."
He said the cabinet's top priority would be to resettle those still living rough because of the violence and paid tribute to the "patience" of the Kenyan people while the negotiations were conducted.
He promised a "new, inclusive" Kenya.
"We can now consign Kenya's past failures of grand corruption and grand tribalism to our history books."
The ceremony was presided over by President Kibaki at State House, his official residence.
Mr Kibaki and Mr Odinga were allies in the 2002 election but fell out when the president did not name Mr Odinga prime minister after taking office, as they had reportedly agreed.
Some question whether the two men and their supporters can work together after such a bitter dispute.
KEY CABINET POSTS
Prime Minister: Raila Odinga (ODM)
Vice-President and Home Affairs: Kalonzo Musyoka (Pro-Kibaki)
Finance Minister: Amos Kimunya (Pro-Kibaki)
Deputy PM and Trade: Uhuru Kenyatta (Pro-Kibaki)
Deputy PM and Local Government: Musalia Mudavadi (ODM)
Former UN Secretary General Kofi Annan, who mediated the deal, was among the dignitaries who witnessed the ceremony in the capital, Nairobi.
Uganda's President Yoweri Museveni and other East African leaders were also in attendance. The crisis in Kenya had an impact across the region.
In response to his speech, the outlawed Mungiki sect called off protests that have led to the deaths of 14 people in the past few days.
Mungiki spokesman Njuguna Gitau Njuguna said the group, mainly drawn from Mr Kibaki's Kikuyu ethnic group, wanted to give Mr Odinga time to address its grievances, which include the release of its jailed leader.
Mr Annan said much work remained to be done, but he hoped the new government would form a "cohesive, effective and productive team".
The government includes 40 ministers and 52 deputy ministers, with posts evenly divided across the country's ethnic communities.
It is the largest cabinet that Kenya has seen since independence.
The swearing in of the Kenyan coalition government
There has been criticism of its size and the cost to Kenyan taxpayers, says the BBC's Karen Allen in Nairobi.
Each minister is to be paid between $15,000 and $18,000 a month and entitled to two officials cars and five security personnel - and in the case of Mr Odinga, 45 security personnel.
Mr Odinga has said that he knows people would have preferred a leaner cabinet, but it was a price that had to be paid to balance everyone's interests.
Our correspondent says that other than resettling the displaced, longer term challenges will be constitutional change and land reform.
The political violence ignited land disputes between rival ethnic groups.
Another challenge will be to curb corruption which has blighted Kenya's government for many years.
Mr Kibaki was first elected on a pledge to tackle corruption but donors say little has changed.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.