A man stands near flowers layed at Potters Fields Park in London. (Chris J Ratcliffe/Agence France-Presse via Getty Images)

BRITAIN CONTINUES to respond with impressive fortitude and sobriety to a string of terrorist attacks claimed by the Islamic State. London bar customers who suddenly found themselves confronting armed attackers Saturday responded by hurling glasses and stools at them. Police ended the assault by shooting and killing the terrorists just eight minutes after the first emergency call. Though the country is only days away from a hard-fought and surprisingly close parliamentary election, both Prime Minister Theresa May and her opponents responded with relatively substantive proposals and arguments rather than rhetorical incitement.

The latter was left to President Trump, who would appear to be doing his best to ruin U.S. relations with its closest ally — if any calculation can be imputed to his reckless and irresponsible tweets. Even before expressing support for the British people, Mr. Trump tried to use the latest attack to justify his misguided ban on travel to the United States from six predominately Muslim countries. Then he chose to attack London’s popular Muslim mayor, misrepresenting his statement urging people not to be alarmed by a heightened police deployment and, predictably, doubling down when the distortion was widely ridiculed.

In fact, Mayor Sadiq Khan has been principled as well as responsible in reacting to the attack. While urging Londoners to remain calm, the city’s first Muslim mayor said he was “angry and furious” that the terrorists “are seeking to justify their actions by using the faith I belong to.” Displaying a restraint that is glaringly absent in the White House, he had his spokesman respond to Mr. Trump’s provocation by saying Mr. Khan “has more important things to do than respond to Donald Trump’s ill-informed tweet.”

For her part, Ms. May also called on citizens to “go about their lives as they normally would” while stressing the need for better measures to combat the “evil ideology of Islamist extremism.” She rightly observed that it “cannot be defeated by military intervention alone” or by “the maintenance of a permanent, defensive counterterrorism operation.” Instead Britain must convince all its citizens that “pluralistic, British values” are superior to ideological extremism; to do so, more must be done to reach out to “separated, segregated communities.” That wisdom applies not just to Britain but also to nations across continental Europe where de facto Muslim ghettos fester.

Other proposals from Ms. May were less grounded. She pushed for more powers for police in a society where surveillance already is pervasive, as well as “international agreements that regulate cyberspace” — something that would be unlikely to eliminate extremist propaganda but could open the way to greater limits on free expression and privacy. Hammered by Labour Party leader Jeremy Corbyn over cuts to police forces, she ducked.

Whether Ms. May’s fragile-looking lead over Mr. Corbyn will be helped or harmed by all this will be evident on Thursday when Britons go to the polls. What’s already clear is that Mr. Trump has done himself and U.S.-British relations another disservice. Ms. May has tried to build a constructive relationship with the Trump administration; even if she wins handily, she now will have less political leeway to do so. Britain is holding steady under terrorist attack. But U.S. global leadership is in free fall.