Giving his first speech as prime minister on Tuesday, Cameron, at 43 the country's youngest leader in nearly 200 years, admitted running Britain's first coalition government since 1945 would be tough.
"This is going to be hard and difficult work. A coalition will throw up all sorts of challenges. But I believe together we can provide that strong and stable government that our country needs," Cameron said, his pregnant wife Samantha by his side in front of the prime minister's residence at 10 Downing Street.
Liberal Democrat: 57
Al Jazeera's Alan Fisher, reporting from London, said the power-sharing agreement was the work of five days of intense negotiations.
"But now Britain has a new government. The Liberal Democrats will be full partners in the coalition with seats in the cabinet, and more power than the election results perhaps suggested," he said.
Cabinet positions were still being finalised but Cameron's Conservatives said former party leader William Hague will serve as foreign minister, senior legislator George Osborne, a close friend of Cameron's, will become the new finance minister, known as the chancellor of the exchequer, and legislator Liam Fox will be the defence minister.
The prime minister's office announced late in the evening that the Liberal Democrats will have five positions - including Clegg's - in the cabinet.
First among the new government's challenges will be how to reduce Britain's record budget deficit, which is running at more than 11 per cent of national output and has raised fears that the country could lose its triple-A credit rating.
"We have some deep and pressing problems - a huge deficit, deep social problems, a political system in need of reform," Cameron said on Tuesday. "For those reasons, I aim to form a proper and full coalition between the Conservatives and the Liberal Democrats."
|Cameron said the UK has some 'deep and pressing problems' [EPA]
"Nick Clegg and I are both political leaders who want to put aside party differences and work hard for the common good and for the national interest," he said.
Markets had been impatient to see an end to the uncertainty thrown up by last week's election and Britain's sterling currency rose against the dollar and the euro as Cameron spoke.
But some in the finance industry have expressed doubts about Osborne being finance minister because he is untested and takes over an economy emerging from the worst recession since the second world war.
A Conservative source said the two parties had agreed to significantly accelerate deficit reduction plans, with the focus more on cutting public spending than on raising taxes.
US affirms 'special relationship'
The leaders of Germany and France congratulated Cameron soon after he took office, and Barack Obama, the US president, invited the new prime minister to visit Washington DC in July.
Obama and Cameron discussed by phone Afghanistan, Iran, and the Middle East, according to Cameron's office.
Cameron and Clegg have expressed doubts over the Afghanistan mission, but Cameron has pledged not to withdraw British troops for at least five years.
Obama said he looked forward to meeting Cameron at an international economic summit in late June, in Canada.
"I reiterated my deep and personal commitment to the special relationship between our two countries," he said in a statement.
Obama also thanked Brown for his friendship and said Brown "provided strong leadership during challenging times, and I have been grateful for his partnership".
Standing outside the prime minister's residence on Tuesday, alongside his wife Sarah, Brown wished "the next prime minister well as he makes the important choices for the future".
|Brown wished Cameron well as he left office on Tuesday [EPA]
"Only those who have held the office of prime minister can understand the full weight of its responsibilities and its great capacity for good," he said.
Brown said he had "loved the job, not for its prestige, its titles and its ceremony, which I do not love at all", but "for its potential to make this country I love fairer, more tolerant, more green, more democratic, more prosperous, more just - truly a greater Britain".
After his farewell remarks, he went to Buckingham Palace where Queen Elizabeth II accepted his resignation.
He then went to Labour's headquarters, where he told staff that his deputy, Harriet Harman, would serve as interim Labour leader until the party formally chooses a new leader.