The agreement between the two parties, reached five days after an inconclusive election, ends 13 years of rule by the centre-left Labour Party under Tony Blair and his successor Gordon Brown.
The untested partnership will have to clean up public finances, with a record budget deficit running at more than 11% of national output.
Markets welcomed the agreement, hopeful that a government led by the centre-right Conservatives will take swift action to bring down spending.
"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 in his first speech as prime minister.
The Liberal Democrats were also celebrating after decades spent in the shadow of Labour and the Conservatives.
"There will of course be problems, there will of course be glitches. But I will always do my best to prove new politics isn't just possible, it is also better," Liberal Democrat leader Nick Clegg, who will be deputy prime minister, told reporters.
His party put its final seal of approval on the deal at a meeting that ended after midnight on Tuesday.
43-year-old Cameron took over as prime minister just hours earlier, when Brown admitted defeat in his own efforts to broker a deal with the Liberal Democrats.
He is Britain's youngest prime minister since 1812, and a few months younger than Tony Blair was when he stormed to power in 1997.
Tories had been torn apart by wrangling over Europe after the resignation of its long-serving Prime Minister Margaret Thatcher. A move to the right had failed to enthuse voters.
Cameron, a fresh-faced former public relations executive, broke with the Conservatives' image as the "nasty party," moving it toward the centre, stressing its commitment to defending the state-run National Health Service and giving it a pro-environment makeover.
Clegg and Cameron have much in common. They are the same age. Cameron is the Eton-educated son of a stockbroker, Clegg the privately educated son of a banker. Cameron was at university in Oxford, Clegg at Cambridge.
Clegg has enjoyed a rapid rise since entering British politics in 2005, becoming party leader two years later.
Born to a Dutch mother and half-Russian father, and married to a Spanish lawyer, he is the most pro-European Union of the main party leaders and speaks five languages.
Clegg was an adviser at the European Commission before becoming a member of the European Parliament from 1999 to 2004.
The Liberal Democrats have more in common with Labour in policy terms, but talks to form what the media called a "coalition of losers" swiftly fell apart.
The Conservatives are the largest party in parliament after last week's election but fell 20 seats short of an outright majority. Combined with the Liberal Democrats, they will have a majority of 76 seats.
Osborne to be finance chief
The prime minister's office announced late on Tuesday there would be five Liberal Democrats in cabinet in total, including Clegg.
It did not name the other four ministers but there were reports Vince Cable, the highly regarded Liberal Democrat Treasury spokesman, would be given a role overseeing banking and business.
A Conservative source said the two parties had agreed to significantly accelerate deficit reduction plans. The focus would be more on cutting public spending than on raising taxes.
Another Conservative source said George Osborne, a close friend and ally of Cameron, would become the new Chancellor of the Exchequer (finance minister).
Some in the finance industry have expressed doubts about Osborne because he is untested and takes over an economy emerging from the worst recession since World War Two.
William Hague, a former Conservative leader and one of the main negotiators with the Liberal Democrats, will be foreign minister.
Gordon Brown gave an emotional farewell speech flanked by his wife, Sarah, and with his children close by.
He said that it had been his fault - and his fault alone – that the Labour Party had not won a majority but that it had been "a privilege to serve".
Brown, who held hands with his two boys, Jon, 6 and Fraser, 3, said as he left No. 10 that this had been the "second most cherished job" of his life and that "husband and father" was first.
He shocked his party by saying that he would immediately leave parliament as well as the prime ministership, catapulting his deputy, Harriet Harman, into the caretaker leader's role.
(EurActiv with Reuters.)