As David Cameron leaves Downing Street, Justin Parkinson looks at the varied reasons why 13 of his predecessors departed from office.

Image copyright Getty Images

1) Sir Robert Walpole, 1742

Image copyright Getty Images

Widely acknowledged as the first prime minister, although he never actually held the title, he was also the longest-serving, lasting 21 years. But a poor general election result in 1741 cut his majority significantly. In 1742, when the House of Commons was asked to vote on the validity of an allegedly rigged by-election in Chippenham, Walpole was defeated. He agreed to resign.

2) Lord North, 1782

Image copyright Getty Images

Lord North set the unpleasant precedent of being the first prime minister to lose a vote of no confidence, following repeated failures and embarrassments in the American War of Independence. He had previously proposed that all disagreeable acts by the colonies would be forgotten if they stopped the war. But the colonies rejected the plan, as their motivation was independence. He had also begged George III to be allowed to resign, but the King refused to release him until hostilities were over. The vote of no confidence took place after the loss of the Battle of Yorktown. Lord North resigned and has, for many observers, become a benchmark for failure in office.

3) William Pitt the Younger, 1801

Image copyright Getty Images

Pitt, the youngest prime minister in history, entered Downing Street aged 24, and stayed in office for more than 17 years. By the end, the continuing war with France had exacerbated religious and political tensions in Ireland. Pitt's government pushed through the Act of Union between Britain and Ireland, which came into effect on 1 January 1801. In addition, the prime minister wanted to grant more liberties to Catholics, who made up the majority of people in Ireland, through the Emancipation of Catholics Bill. However, George III thought this would contravene his duty to protect the Church of England. Pitt, unable to persuade him to change his mind, resigned.

4) Spencer Perceval, 1812

Image copyright Getty Images

Whereas four serving US presidents have been assassinated, Perceval is the only British prime minister to share their unfortunate fate. On 11 May 1812 he was on his way to attend a parliamentary inquiry into the Luddite riots in the industrial towns of northern England. Entering the House of Commons lobby, he was shot by a merchant called John Bellingham, furious that the government had not compensated him for debts run up in Russia. Bellingham gave himself up and was later hanged. Perceval's last words were: "Oh, I have been murdered."

5) Robert Peel, 1846

Image copyright Getty Images

Peel resigned after winning - not losing - one of the biggest parliamentary battles in history, over the abolition of the Corn Laws. These put a tariff on corn from abroad so as to protect UK farmers. Peel and others had long argued for a more free-trade approach. The Irish potato famine, in which up to one million people eventually died, increased the clamour to repeal the Corn Laws and increase the food supply. After six months of debate, the Corn Laws were repealed, but Peel's Tories were bitterly divided. On the same day he won the main vote, he lost another one and resigned. Unusually for an outgoing prime minister, Peel was cheered by crowds as he left the Commons.

6) William Gladstone, 1894

Image copyright Getty Images

Gladstone's fourth term as prime minister was overshadowed by his insistence on introducing a third bill promising "home rule" for Ireland. As long ago as 1865 he had pronounced: "My mission is to pacify Ireland." But the Conservative-dominated House of Lords threw the bill out and generally obstructed Gladstone's Liberals' attempts to pass the legislation. With his cabinet split and his health failing, Gladstone resigned for the last time.

7) Neville Chamberlain, 1940

Image copyright Getty Images

If World War Two was the making of Winston Churchill as a major historical figure, it was the ruin of Chamberlain's reputation. The long-term advocate of appeasing Germany in order to avoid another Great War was chastened and vilified by the disastrous Norway Campaign in 1940, which failed to prevent Hitler's invasion of that country. Some 40 Tory backbenchers rebelled in a vote on the issue, although Chamberlain narrowly won. When Germany invaded the Netherlands, Belgium and France, opposition to him increased. The Labour Party refused to serve with him in an all-party government and he resigned. Chamberlain died less than six months afterwards.

8) Winston Churchill, 1945

Image copyright Getty Images

Despite Churchill's enormous personal popularity from being the prime minister who won World War Two, the mood of voters had changed by the time of the 1945 general election, some two months after fighting ended in Europe. With Labour's Clement Attlee promising a welfare state, including a National Health Service, Churchill's Tories lost power. Labour gained a 146-seat majority in the Commons.

9) Anthony Eden, 1957

Image copyright Getty Images

Following Egypt's decision to nationalise the Suez Canal, Britain, France and Israel invaded in October 1956 to widespread international condemnation and the threat of nuclear strikes by the Soviet Union. Within a week, Britain was forced into an embarrassing climbdown. Humiliated and in ill health, Eden left the country for a holiday in Jamaica. Eden, who had laboured for many years in Churchill's shadow, returned in mid-December but his long-standing gall bladder condition did not improve. He resigned on 9 January 1957.

10) Harold Macmillan, 1963

Image copyright Getty Images

Macmillan had for months been dogged by a sex scandal involving War Secretary John Profumo and a showgirl who had also been seeing the Soviet naval attache to London. He had also dismissed six cabinet ministers in 1962 - the so-called "night of the long knives" - in an attempt to bolster his government's faltering popularity. But what did for the beleaguered Macmillan was his diagnosis of inoperable prostate cancer. He quit on 18 October but, it later transpired, the doctors had been wrong. Macmillan, who took a peerage in 1984 but never re-entered mainstream politics, lived until 1986.

11) Harold Wilson, 1976

Image copyright Getty Images

Wilson surprised everyone when he resigned in March 1976, saying that he had lost interest in the grind of day-to-day politics. Since coming to power for a second time in 1974, he had held a referendum on the UK's membership of the European Economic Community - in an effort to avoid a split through the middle of his Labour Party - and seen a collapse in the value of the pound. Wilson later told BBC journalists he thought MI5 had been trying to undermine him.

12) Margaret Thatcher, 1990

Image copyright Getty Images

In the most dramatic political departure of recent times, Mrs Thatcher was effectively deposed by her own party. She stood down after 11 years in office after taking soundings from members of her cabinet ahead of a second round of leadership elections. Controversial policies including the poll tax and her opposition to any closer integration with Europe produced divisions within the Conservative Party which led to a leadership challenge from former cabinet minister Michael Heseltine. Although Thatcher won the vote among Tory MPs, she did not win the backing of enough to avoid a second ballot and decided to resign after the meetings with senior ministers.

13) Tony Blair, 2007

Image copyright Getty Images

It was perhaps the most rapturous departure a prime minister has made. After Blair gave his last Commons performance, in Prime Minister's Questions on 27 June, opposition leader David Cameron instructed his MPs to stand and applaud. But his time in office had been known for what insiders called Labour's "TB-GBs", the jostling for power between the PM and Chancellor Gordon Brown. They had reached a deal in 1994. Before fighting - and winning - his third general election in 2005, Blair had said he would serve one last full term. But Brown's supporters pushed for Blair to go sooner, launching a so-called coup in 2006. Eventually, he succumbed, resigning after just over a decade in Downing Street. "I don't think we'll miss you," Blair's wife Cherie told the press as the family left.