# List of prime ministers of the United Kingdom by length of tenure

This is a list of prime ministers of the United Kingdom by length of tenure. This is based on the difference between dates; if counted by the number of calendar days, the figures would be one day greater for each term served.
The term prime minister appeared in the early eighteenth century as an unofficial title for the leader of the government, usually the head of the Treasury. Jonathan Swift, for example, wrote that in 1713 there had been "those who are now commonly called Prime Minister among us", referring to Sidney Godolphin and Robert Harley, Queen Anne's lord treasurers and chief ministers. Robert Walpole is regarded as the first prime minister; he became First Lord of the Treasury of Great Britain in 1721. This list includes all prime ministers of the Kingdom of Great Britain, the United Kingdom of Great Britain and Ireland, and the modern-day United Kingdom of Great Britain and Northern Ireland.

## Notable lengths

Of the 57 past prime ministers, nine served more than 10 years while eight served less than a year. Robert Walpole is the only person to have served as prime minister for more than two decades. Liz Truss is the shortest-serving prime minister, resigning after seven weeks. The previous shortest time served was George Canning, who served for less than four months before dying in office. Margaret Thatcher, in office for 11 years and 208 days between 1979 and 1990, is the longest-serving prime minister in modern history, and the longest-serving prime minister officially referred to as such. William Gladstone is the only person to have served four separate terms.

## List of office holders by tenure

* Conservative (20)
* Whig (16)
* Tory (10)
* Labour (7)
* Liberal (7)
* Scottish Unionists (2)
* National Labour (1)
* Peelite (1)
| Rank | Prime Minister | Party | Start | End | Tenure length (term) | Tenure length (total) | Reason for exit |
| 1 | Sir Robert Walpole | Whig | 3 April 1721 | 11 February 1742 | 20 years, 315 days | 20 years, 315 days | Resigned |
| 2 | William Pitt the Younger | Tory (Pittite) | 19 December 1783 | 14 March 1801 | 17 years, 86 days | 18 years, 345 days | Resigned |
| 2 | William Pitt the Younger | Tory (Pittite) | 10 May 1804 | 23 January 1806 | 1 year, 259 days | 18 years, 345 days | Died |
| 3 | The Earl of Liverpool | Tory (Pittite) | 8 June 1812 | 9 April 1827 | 14 years, 306 days | 14 years, 306 days | Resigned due to illness |
| 4 | The Marquess of Salisbury | Conservative | 23 June 1885 | 28 January 1886 | 220 days | 13 years, 255 days | Resigned |
| 4 | The Marquess of Salisbury | Conservative | 25 July 1886 | 11 August 1892 | 6 years, 18 days | 13 years, 255 days | Defeated in election |
| 4 | The Marquess of Salisbury | Conservative | 25 June 1895 | 11 July 1902 | 7 years, 17 days | 13 years, 255 days | Resigned due to illness |
| 5 | William Ewart Gladstone | Liberal | 3 December 1868 | 17 February 1874 | 5 years, 77 days | 12 years, 130 days | Defeated in election |
| 5 | William Ewart Gladstone | Liberal | 23 April 1880 | 9 June 1885 | 5 years, 48 days | 12 years, 130 days | Defeated in election |
| 5 | William Ewart Gladstone | Liberal | 1 February 1886 | 20 July 1886 | 170 days | 12 years, 130 days | Resigned |
| 5 | William Ewart Gladstone | Liberal | 15 August 1892 | 2 March 1894 | 1 year, 200 days | 12 years, 130 days | Resigned |
| 6 | Lord North | Tory (Northite) | 28 January 1770 | 27 March 1782 | 12 years, 59 days | 12 years, 59 days | Resigned |
| 7 | Margaret Thatcher | Conservative | 4 May 1979 | 28 November 1990 | 11 years, 209 days | 11 years, 209 days | Resigned |
| 8 | Henry Pelham | Whig | 27 August 1743 | 6 March 1754 | 10 years, 192 days | 10 years, 192 days | Died |
| 9 | Tony Blair | Labour | 2 May 1997 | 27 June 2007 | 10 years, 57 days | 10 years, 57 days | Resigned |
| 10 | The Viscount Palmerston | Whig | 6 February 1855 | 19 February 1858 | 3 years, 14 days | 9 years, 143 days | Resigned |
| 10 | The Viscount Palmerston | Liberal | 12 June 1859 | 18 October 1865 | 6 years, 129 days | 9 years, 143 days | Died |
| 11 | H. H. Asquith | Liberal | 8 April 1908 | 5 December 1916 | 8 years, 243 days | 8 years, 243 days | Resigned |
| 12 | Sir Winston Churchill | Conservative | 10 May 1940 | 26 July 1945 | 5 years, 78 days | 8 years, 240 days | Defeated in election |
| 12 | Sir Winston Churchill | Conservative | 26 October 1951 | 5 April 1955 | 3 years, 162 days | 8 years, 240 days | Resigned due to illness |
| 13 | Harold Wilson | Labour | 16 October 1964 | 19 June 1970 | 5 years, 247 days | 7 years, 280 days | Defeated in election |
| 13 | Harold Wilson | Labour | 4 March 1974 | 5 April 1976 | 2 years, 33 days | 7 years, 280 days | Resigned |
| 14 | The Duke of Newcastle | Whig | 16 March 1754 | 11 November 1756 | 2 years, 241 days | 7 years, 207 days | Dismissed |
| 14 | The Duke of Newcastle | Whig | 29 June 1757 | 26 May 1762 | 4 years, 332 days | 7 years, 207 days | Dismissed |
| 15 | Stanley Baldwin | Conservative | 22 May 1923 | 22 January 1924 | 246 days | 7 years, 85 days | Lack of majority after election |
| 15 | Stanley Baldwin | Conservative | 4 November 1924 | 4 June 1929 | 4 years, 213 days | 7 years, 85 days | Defeated in election |
| 15 | Stanley Baldwin | Conservative | 7 June 1935 | 28 May 1937 | 1 year, 356 days | 7 years, 85 days | Resigned |
| 16 | Benjamin Disraeli | Conservative | 27 February 1868 | 1 December 1868 | 279 days | 6 years, 341 days | Election |
| 16 | Benjamin Disraeli | Conservative | 20 February 1874 | 21 April 1880 | 6 years, 62 days | 6 years, 341 days | Election |
| 17 | Ramsay MacDonald | Labour | 22 January 1924 | 4 November 1924 | 288 days | 6 years, 291 days | Defeated in election |
| 17 | Ramsay MacDonald | Labour / National Labour | 5 June 1929 | 7 June 1935 | 6 years, 3 days | 6 years, 291 days | Resigned due to illness |
| 18 | Harold Macmillan | Conservative | 10 January 1957 | 18 October 1963 | 6 years, 282 days | 6 years, 282 days | Resigned due to illness |
| 19 | The Viscount Melbourne | Whig | 16 July 1834 | 14 November 1834 | 122 days | 6 years, 257 days | Dismissed |
| 19 | The Viscount Melbourne | Whig | 18 April 1835 | 30 August 1841 | 6 years, 135 days | 6 years, 257 days | Defeated in election |
| 20 | John Major | Conservative | 28 November 1990 | 2 May 1997 | 6 years, 156 days | 6 years, 156 days | Defeated in election |
| 21 | Lord John Russell | Whig | 30 June 1846 | 21 February 1852 | 5 years, 237 days | 6 years, 112 days | Defeated in election |
| 21 | Lord John Russell | Liberal | 29 October 1865 | 26 June 1866 | 241 days | 6 years, 112 days | Resigned |
| 22 | Clement Attlee | Labour | 26 July 1945 | 26 October 1951 | 6 years, 93 days | 6 years, 93 days | Defeated in election |
| 23 | David Cameron | Conservative | 11 May 2010 | 13 July 2016 | 6 years, 64 days | 6 years, 64 days | Resigned |
| 24 | David Lloyd George | Liberal | 6 December 1916 | 19 October 1922 | 5 years, 318 days | 5 years, 318 days | Resigned |
| 25 | Sir Robert Peel | Conservative | 10 December 1834 | 8 April 1835 | 120 days | 5 years, 57 days | Defeated in election |
| 25 | Sir Robert Peel | Conservative | 30 August 1841 | 29 June 1846 | 4 years, 304 days | 5 years, 57 days | Resigned |
| 26 | The Earl of Derby | Conservative | 23 February 1852 | 17 December 1852 | 299 days | 3 years, 283 days | No confidence vote |
| 26 | The Earl of Derby | Conservative | 20 February 1858 | 11 June 1859 | 1 year, 112 days | 3 years, 283 days | No confidence vote |
| 26 | The Earl of Derby | Conservative | 28 June 1866 | 25 February 1868 | 1 year, 243 days | 3 years, 283 days | Resigned due to illness |
| 27 | Edward Heath | Conservative | 19 June 1970 | 4 March 1974 | 3 years, 259 days | 3 years, 259 days | Defeated in election |
| 28 | The Earl Grey | Whig | 22 November 1830 | 9 July 1834 | 3 years, 230 days | 3 years, 230 days | Resigned |
| 29 | Arthur Balfour | Conservative | 12 July 1902 | 4 December 1905 | 3 years, 146 days | 3 years, 146 days | Resigned |
| 30 | The Duke of Portland | Whig | 2 April 1783 | 18 December 1783 | 261 days | 3 years, 83 days | Lost a vote in the Lords |
| 30 | The Duke of Portland | Tory (Pittite) | 31 March 1807 | 4 October 1809 | 2 years, 188 days | 3 years, 83 days | Resigned due to illness |
| 31 | Henry Addington | Tory (Pittite) | 17 March 1801 | 10 May 1804 | 3 years, 55 days | 3 years, 55 days | Replaced |
| 32 | Boris Johnson | Conservative | 24 July 2019 | 6 September 2022 | 3 years, 45 days | 3 years, 45 days | Resigned |
| 33 | James Callaghan | Labour | 5 April 1976 | 4 May 1979 | 3 years, 30 days | 3 years, 30 days | Defeated in election |
| 34 | Theresa May | Conservative | 13 July 2016 | 24 July 2019 | 3 years, 12 days | 3 years, 12 days | Resigned |
| 35 | Neville Chamberlain | Conservative | 28 May 1937 | 10 May 1940 | 2 years, 357 days | 2 years, 357 days | Resigned |
| 36 | The Duke of Wellington | Tory | 22 January 1828 | 16 November 1830 | 2 years, 299 days | 2 years, 322 days | Replaced |
| 36 | The Duke of Wellington | Tory | 17 November 1834 | 9 December 1834 | 23 days | 2 years, 322 days | Caretaker |
| 37 | Gordon Brown | Labour | 27 June 2007 | 11 May 2010 | 2 years, 319 days | 2 years, 319 days | Defeated in election |
| 38 | Spencer Perceval | Tory (Pittite) | 4 October 1809 | 11 May 1812 | 2 years, 221 days | 2 years, 221 days | Assassinated |
| 39 | Sir Henry Campbell-Bannerman | Liberal | 5 December 1905 | 3 April 1908 | 2 years, 121 days | 2 years, 121 days | Resigned due to illness |
| 40 | George Grenville | Whig (Grenvillite) | 16 April 1763 | 10 July 1765 | 2 years, 86 days | 2 years, 86 days | Replaced |
| 41 | The Earl of Chatham | Whig (Chathamite) | 30 July 1766 | 14 October 1768 | 2 years, 77 days | 2 years, 77 days | Resigned due to illness |
| 42 | The Earl of Aberdeen | Peelite | 19 December 1852 | 30 January 1855 | 2 years, 43 days | 2 years, 43 days | Resigned |
| 43 | Sir Anthony Eden | Conservative | 6 April 1955 | 9 January 1957 | 1 year, 279 days | 1 year, 279 days | Resigned due to illness |
| 44 | Rishi Sunak | Conservative | 25 October 2022 | 5 July 2024 | 1 year, 255 days | 1 year, 255 days | Defeated in election |
| 45 | The Earl of Wilmington | Whig | 16 February 1742 | 2 July 1743 | 1 year, 137 days | 1 year, 137 days | Died |
| 46 | The Marquess of Rockingham | Whig (Rockinghamite) | 13 July 1765 | 30 July 1766 | 1 year, 18 days | 1 year, 115 days | Resigned |
| 46 | The Marquess of Rockingham | Whig (Rockinghamite) | 27 March 1782 | 1 July 1782 | 97 days | 1 year, 115 days | Died |
| 47 | The Earl of Rosebery | Liberal | 5 March 1894 | 22 June 1895 | 1 year, 110 days | 1 year, 110 days | Election |
| 48 | The Duke of Grafton | Whig (Chathamite) | 14 October 1768 | 28 January 1770 | 1 year, 107 days | 1 year, 107 days | Resigned |
| 49 | The Lord Grenville | Whig | 11 February 1806 | 25 March 1807 | 1 year, 43 days | 1 year, 43 days | Replaced |
| 50 | Sir Alec Douglas-Home | Conservative (Scot. Unionist) | 18 October 1963 | 16 October 1964 | 365 days | 365 days | Defeated in election |
| 51 | The Earl of Bute | Tory | 26 May 1762 | 8 April 1763 | 318 days | 318 days | Resigned |
| 52 | The Earl of Shelburne | Whig (Chathamite) | 4 July 1782 | 26 March 1783 | 266 days | 266 days | Replaced |
| 53 | Sir Keir Starmer | Labour | 5 July 2024 | Incumbent | 231 days | 231 days | |
| 54 | The Duke of Devonshire | Whig | 16 November 1756 | 29 June 1757 | 226 days | 226 days | Replaced |
| 55 | Andrew Bonar Law | Conservative (Scot. Unionist) | 23 October 1922 | 20 May 1923 | 210 days | 210 days | Resigned due to illness |
| 56 | The Viscount Goderich | Tory (Canningite) | 31 August 1827 | 8 January 1828 | 131 days | 131 days | Replaced |
| 57 | George Canning | Tory (Canningite) | 12 April 1827 | 8 August 1827 | 119 days | 119 days | Died |
| 58 | Liz Truss | Conservative | 6 September 2022 | 25 October 2022 | 49 days | 49 days | Resigned |

### Disputed

| Portrait | Prime Minister | Party | Start | End | Tenure length | Reason for exit |
| | The Earl Waldegrave | Whig | 8 June 1757 | 12 June 1757 | 5 days | Unsupported |
| | The Earl of Bath | Whig | 10 February 1746 | 12 February 1746 | 3 days | Unsupported |