Robert Banks Jenkinson , 2nd Earl of Liverpool ( 7 June 1770 â `` 4 December 1828 ) was an English politician and the longest serving Prime Minister of the United Kingdom ( Robert Walpole held office for longer , but only as Prime Minister of Great Breat Britain ) During his time as Prime Minister from 1812 to 1827 , Liverpool became known for the harsh rules he put in place to restore order , but he also led the country through the bad period that followed the Napoleonic Wars . Robert Banks Jenkinson , 2nd Earl of Liverpool KG PC ( 7 June 1770 -- 4 December 1828 ) was a British politician and the longest-serving Prime Minister of the United Kingdom since the Union with Ireland in 1801 .