The Doctor knew the Prime Minister before his exile on Earth. Benjamin Disraeli was present at Parliament when Ramón Salamander offered the British government his micro machines and services as a scientific advisor. Disraeli was won over by Salamander's demonstration and was ready to accept his offer before the Third Doctor took control of the micro machines and the Master wiped the memories of all the politicians. (COMIC: The Heralds of Destruction)
The Second Doctor remembered a saying from Benjamin Disraeli, 'Everyone likes flattery – and when you come to royalty, you should lay it on with a trowel.' (PROSE: World Game) The Third Doctor remembered the same saying. (PROSE: Deadly Reunion)
Behind the scenes
In the real world, Benjamin Disraeli changed the spelling of his last name from "D'Israeli" to "Disraeli" in 1822, decades before becoming Prime Minister. Nonetheless, COMIC: The Heralds of Destruction used the original spelling.
Disraeli was portrayed by Patrick Troughton in the 1974 television series Jennie: Lady Randolph Churchill.