Timothy Stanley, a conservative, is a historian and columnist for Britain's Daily Telegraph. He is the author of " Citizen Hollywood: How the Collaboration Between LA and DC Revolutionized American Politics ." The opinions expressed in this commentary are his.

(CNN) Europe is waking up to the need for change. We've been fighting the war on terror for a very long time, but we've recently seen an escalation. Tuesday, in France -- which is still in a state of emergency since the 2015 Paris attacks -- a man attacked police officers with a hammer, and officials have opened an anti-terror probe into the incident.

Britain, my country, has suffered three attacks in three months; in the last, at London Bridge , seven people lost their lives to terrorists. As we mourn these dead, the very last thing we expect or need is a US president to insult the mayor of London. And yet Donald Trump launched a series of disgraceful attacks on Sadiq Khan on Twitter.

Khan has called for the President's forthcoming state visit to the UK to be canceled. I disagree. Trump is u ndiplomatic and ignorant. But he remains Britain's closest ally and -- please don't tell any Europeans I wrote this --he's not wrong about everything. There's a lot he gets right.

The challenges faced by America and Europe are different. America is a target for terrorists but is also isolated by geography. Europe sits on the edge of the Islamic world and has a large, overwhelmingly peaceful population of Muslims within its borders. I cannot stress how integrated -- to use a patronizing term -- those Muslims are, and proof of that is Khan himself.

The son of Pakistani Sunni migrants, Khan is a feminist and pro-gay; he's a successful lawyer, a left-wing icon and now mayor of, I'd argue, the greatest city in Europe. He could easily be a future prime minister. One reason why Donald Trump's Islamophobia comes off so poorly in Britain is that it contradicts our experience of living side-by-side with Muslims.

JUST WATCHED Clinton: Not a time to lash out Replay More Videos ... MUST WATCH Clinton: Not a time to lash out 01:43

Our real problems are twofold. One, we have to deal with the rise of a political ideology that calls itself Islamic and radicalizes people into terrorism. The other problem is mass migration, which creates the pool of potential recruits and a pathway into Europe for those exporting terror.

Europe has accepted a large number of people from the developing world at a rate so fast that it has overwhelmed parts of the host population. This is not my judgment, but the judgment of the very Europeans who let those migrants in. The liberal elite that two years ago announced that we would welcome anyone who could make it here is now sending them home.

Britain has taken in refugees from Syria; Muslim migration mostly arrives here from the former British colonies of Bangladesh and Pakistan. Again, most of these folks are as British as I am -- but some do not integrate, and segregation in inner cities is becoming self-evident. This exacerbates that toxic mix of politics, race and religion that has given the security services the job of having to trace an estimated 23,000 subjects of interest.

They're failing. Time after time, perpetrators of terror attacks turn out to be known to the authorities. One of the men who executed the London Bridge atrocity was actually featured in a TV documentary about radical Islam . He was filmed praying by a jihadi-style flag.

Why wasn't he arrested just for doing that? Because, like the US, we have very liberal speech laws and you can't just throw a man in prison for expressing the wrong view. Our liberal culture is one of the best things about being European, but it also hinders us in fighting those who cynically exploit it. A foreign-born criminal in Britain can delay deportation for years by invoking human rights laws.

JUST WATCHED John Oliver mocks media after London attack Replay More Videos ... MUST WATCH John Oliver mocks media after London attack 01:16

We don't want to close our borders. We don't want to lock innocent people up. We don't want to police free speech -- although we do speak to a script. Whenever a terror attack happens, our politicians say: Everything is under control, keep calm and carry on, nothing must change. This is testing the patience of the public. Things are changing; they've changed dramatically for the families of the dead.

Through this veneer of political correctness, Trump cuts like a knife.

Trump gets it. Not the policy detail or the fine detail of the challenge we face, but he gets the raw, instinctive sense that things can't go on as they are -- that every time the elite say things are fine, they lose credibility and things feel even worse.

The free world was led for eight years by the sublimely intelligent Barack Obama, who left office with things in pretty much the same disorder. The promise that Trump holds out is to be honest about the situation and take the steps necessary to change it. Where he oversteps the line, the law will hopefully restrain him -- as the travel ban illustrates.

JUST WATCHED Trump: This bloodshed will end Replay More Videos ... MUST WATCH Trump: This bloodshed will end 01:01

But he is right about the need for a Western-Israeli-Saudi alliance against terrorism. He is right about the basic need to restore control to migration. He is right to project an image of the West that is tough and unashamedly Western. The West should cease apologizing for what it is.

The British Conservative government stands by the President in part because it needs him: Britain voted to leave the EU, and now Trump is Britain's closest diplomatic partner.

The situation recalls Voltaire, asked on his death bed if he'd renounce the devil; he replied: It's a bit late in life to start making enemies.

So, the state visit will go ahead, and there will be protests. But if Trump could only get off Twitter for five minutes and focus on the essentials of the Western alliance, he'd discover that Europe is edging closer to his way of thinking on the most important issue of our time. There is, increasingly, more agreement between us than disagreement.