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 288 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
In this table, "Terms" is the number of separate periods served as prime minister.