Boris Johnson has just received two significant endorsements in his campaign to become prime minister. One is from Liz Truss, the chief secretary to the Treasury, who had leadership ambitions herself but who decided not to join the crowded field. She is the most senior minister so far to have come out for a candidate who is not him or herself.

The other endorsement comes from the president of the United States. Some of us are old enough to remember three years ago, when Mr Johnson thought American presidents interfering in British politics was a bad idea, because Barack Obama said we would be at the back of the queue for a trade deal if we voted to leave the EU.

But in fact Mr Johnson is probably none too pleased to have Donald Trump saying he would do “a very good job”. Most Conservative MPs would have been Hillary Clinton supporters, if forced to choose, and those are the people Mr Johnson needs to impress first of all in the leadership contest.

It has been a longstanding convention in modern democracies that heads of government avoid commenting on the internal politics of other countries. This is right in principle, in that the workings of democracy ought to be free from outside interference.

But it is also a matter of simple self-interest. It could be argued, cynically, that it helps to be on good terms with a fellow leader by boosting them before they are elected. Although Tony Blair, when he visited Vladimir Putin before his election in 2000, failed in the end to gain anything from this breach in protocol.

But sometimes favoured candidates lose, and that means that relations between two countries are soured by a leader knowing that a fellow president or prime minister had wanted an opponent to win.

Not that President Trump would care if Dominic Raab, Michael Gove or Andrea Leadsom turned out to be the next British prime minister to share an awkward press conference with him.

But the principle still matters. Mr Trump may not be embarrassed by it – indeed, this week he guilelessly tweeted about the Russians “helping me to get elected”. But interfering in other countries’ elections is wrong.

No doubt Mr Trump will interfere some more when he arrives in the UK for a state visit next week. If he meets Nigel Farage – and a British government source said this week that, “if you’re the US president and you want to see someone, you find a way to make it happen” – that would be another breach of protocol. Farage’s Brexit Party is fighting a by-election in Peterborough on Thursday.