Prime Minister Boris Johnson was braced for trouble from Donald Trump's visit just days before Britain's election, but the US president headed home Wednesday having largely kept his promise to stay out of the campaign.

Johnson was forced to deny he was dodging Trump during his visit for a NATO summit, after failing to publicly greet him at Downing Street and holding their face-to-face meeting away from the cameras.

He also sidestepped a question about whether Trump was good for Britain, instead emphasising the strength of transatlantic ties -- while avoiding using Trump's name.

In the end, the unpredictable US leader -- who is deeply unpopular in Britain -- reserved his outspoken remarks for NATO allies France and Canada.

Johnson's governing Conservatives are leading opinion polls for the December 12 election, but were wary of an intervention by Trump that might upset the campaign.

During two previous visits to Britain, Trump was forthright in his views about the country's tortuous exit from the European Union, humiliating the then-premier Theresa May.

The main opposition Labour party sought to whip up public opinion against Trump this time around, focused on Johnson's plans for a US trade deal after Brexit.

Johnson is campaigning for re-election on a promise to leave the EU next month, more than three years after the 2016 Brexit referendum.

He has touted a US trade deal as a prize of Brexit but Labour claims this will open up Britain's much-loved National Health Service (NHS) to US firms.

Johnson has repeatedly denied this and Trump -- who said on a previous visit that "everything is on the table" -- insisted on Tuesday that he had no interest in the NHS.

Arriving for the formal NATO talks on Wednesday, Boris Johnson denied he was trying to avoid being seen with Donald Trump
Arriving for the formal NATO talks on Wednesday, Boris Johnson denied he was trying to avoid being seen with Donald Trump POOL / CHRISTIAN HARTMANN

"We have absolutely nothing to do with it and we wouldn't want to if you handed it to us on a silver platter," he told reporters in an impromptu news conference on Tuesday.

Trump praised Johnson as "very capable" but declined to repeat his previous criticism of Labour's left-wing leader Jeremy Corbyn, who he once said would be bad for Britain.

Instead, he attacked French President Emmanuel Macron as "nasty" for criticising NATO as brain dead.

And after footage emerged of Canada's Justin Trudeau apparently laughing at Trump with other NATO leaders at Buckingham Palace, he called the prime minister "two-faced".

Johnson, who was filmed as part of the group listening to Trudeau at a Buckingham Palace reception on Tuesday, described suggestions he was mocking Trump as "nonsense".

Asked if the president was "good for Britain", the premier praised Washington's support for NATO.

He also hailed US solidarity after a nerve agent attack in Salisbury, southwest England, last year, which was blamed on Russia.

"They were shoulder to shoulder with us and could not have been more supportive," Johnson, who was foreign minister at the time of the attack, told a NATO summit press conference.

Earlier, he insisted he was not dodging Trump, and posed with the president for an official welcome alongside NATO chief Jens Stoltenberg.

US-UK ties are strained over many issues, from climate change to Iran, and Johnson repeated his support for a tax on multinational firms that has enraged Trump.

But he also gave the biggest hint yet that London would bow to US pressure to ban Chinese telecoms giant Huawei from developing Britain's new 5G network.