Donald Trump hailed Boris Johnson as a future prime minister, accused the London mayor, Sadiq Khan, of doing “a bad job” on terrorism and said there had been too much immigration in Europe in an incendiary interview that raised questions about the decision to invite him to Britain.

A day before the US president was due to have bilateral talks with Theresa May, Trump used an interview with the Rupert Murdoch-owned Sun to endorse her principal Tory rival just days after he resigned from the cabinet in protest at her Brexit policy.

Trump described Johnson as “a very talented guy” for whom he had “a lot of respect”. He claimed he was not trying to pit Johnson against his host, but added: “I am just saying I think he would be a great prime minister. I think he’s got what it takes.”

Trump: soft Brexit will 'kill' UK's chances of US trade deal Read more

The president – who has said he would like to see Johnson during his UK trip – added that Johnson “obviously likes me, and says very good things about me. I was very saddened to see he was leaving government and I hope he goes back in at some point. I think he is a great representative for your country.”

Last month, a leaked recording of Johnson revealed that the former foreign secretary was “increasingly admiring of Donald Trump”. The Conservative MP said that Trump would negotiate Brexit “bloody hard”, adding: “There’d be all sorts of breakdowns, all sorts of chaos. Everyone would think he’d gone mad. But actually you might get somewhere. It’s a very, very good thought.”

Trump is due to have a summit meeting with May on Friday at lunchtime before meeting the Queen for tea at Windsor Castle and then heading to Scotland. Protests have been organised to follow him everywhere around the UK, with a demonstration planned for Friday afternoon in London where organisers expect tens of thousands to attend.

Play Video 0:44 Trump receives grand welcome at Blenheim Palace – video

The president renewed his feud with Khan with a series of heavyhanded comments aimed at Johnson’s successor as London mayor, trying to blame him for the spate of fatal terror attacks in the capital last year at Westminster, London Bridge and outside Finsbury Park mosque.

Q&A Tell us: how are you marking Donald Trump's UK visit? Show Hide Whether you are joining a planned demonstration or marking Trump’s UK visit in some other way, share your story and photographs via our callout here.

You can also share your stories, photos and videos with the Guardian via WhatsApp by adding the contact +44(0)7867825056 Your responses will only be seen by the Guardian and we’ll feature some of your contributions in our reporting. You can read terms of service here.

“Take a look at the terrorism that is taking place. Look at what is going on in London,” Trump said, before referring directly to Khan: “I think he has done a very bad job on terrorism. I think he has done a bad job on crime, if you look, all of the horrible things going on there, with all of the crime that is being brought in.”

Trump even appeared to hold Khan personally responsible for immigration in Europe, in comments that were particularly inflammatory. “I think allowing millions and millions of people to come into Europe is very, very sad. I look at cities in Europe, and I can be specific if you’d like. You have a mayor who has done a terrible job in London. He has done a terrible job.”

The US president has repeatedly clashed with the London mayor, tweeting last June after the London Bridge attack that Khan was wrong to call for calm. “At least 7 dead and 48 wounded in terror attack and Mayor of London says there is ‘no reason to be alarmed!’,” Trump said that the time – prompting Khan to call the American leader “ill informed”.

The president returned to the theme of immigration elsewhere in the interview, making further controversial claims: “Allowing the immigration to take place in Europe is a shame. I think it changed the fabric of Europe and, unless you act very quickly, it’s never going to be what it was and I don’t mean that in a positive way.”

Play Video 1:38 'Fragile, like the president's ego': Trump Baby blimp prepares for takeoff

Trump also complained that Khan had given permission for a six-metre-high “Trump baby” blimp to fly over Westminster on Friday. He said he was pleased to be spending little time in the capital on his three-day trip as a result: “I used to love London as a city. I haven’t been there in a long time. But when they make you feel unwelcome, why would I stay there?”

Media owned by Murdoch have repeatedly secured interviews with Trump. In addition to regular appearances on his Fox TV network, Michael Gove, in his brief period as a backbencher, interviewed the US president for the Times in January 2017 while the media mogul was in the room.

In his chronicle of the Trump White House, Fire and Fury, Michael Wolff said that Murdoch is a confidante of Trump, one of a circle of billionaires whom the US president calls to discuss politics and current affairs.