LONDON -- David Cameron, the youthful leader who modernized the party of right-wing icon Margaret Thatcher, became prime minister Tuesday after the resignation of Gordon Brown, capping a gripping election saga that returns the Tories to government after 13 years of Labour Party rule.

According to tradition, Queen Elizabeth II appointed Cameron at Buckingham Palace, the stately denouement to a behind-the-scenes dogfight between Cameron and Brown for the cooperation of Britain's third-place party, after an election last week that left no party with a majority.

Within minutes, Cameron was installed at No. 10 Downing Street and an announcement followed that Liberal Democrat leader Nick Clegg would become deputy prime minister after days of hard bargaining with his former political rivals.

Cameron, 43, becomes Britain's youngest prime minister in almost 200 years -- the last was Lord Liverpool at 42 -- and cemented a coalition deal with the Liberal Democrats. Clegg and four other Liberal Democrats received Cabinet posts. A number of other Liberal Democrats would receive junior posts.

The agreement, reached over five sometimes-tense days of negotiation, delivered Britain's first full coalition government since World War II.

Cameron and Clegg agreed to a pact after the Conservative Party won the most seats in Britain's May 6 national election but fell short of winning a majority of seats in Parliament.

Cameron's Conservative Party said ex-leader William Hague will serve as foreign secretary, senior lawmaker George Osborne as treasury chief and lawmaker Liam Fox as defense secretary.

Other leading positions were being finalized, as were key policy decisions ahead of the presentation of the coalition's first legislative program on May 25.

The coalition already has agreed on a five-year, fixed term Parliament, the first time Britain has had the date of its next election decided in advance. Both sides have made compromises, and Cameron has promised Clegg a referendum on his key issue -- reform of Britain's electoral system aimed at creating a more proportional system.

"We are going to form a new government. More importantly, we are going to form a new kind of government," Clegg said in a news conference after his party's lawmakers overwhelmingly approved his decision to enter a coalition with Cameron.

Arriving at London's Downing Street hand-in-hand with his wife, Samantha, Cameron said he believed that Britain's "best days lie ahead."

Cameron and Clegg have signaled that they favor looser ties to Washington. Both back the Afghanistan mission, but Cameron hopes to withdraw British troops within five years.