LONDON — President Trump’s cancellation of a visit to London to open a new United States embassy was welcomed by his many critics in Britain on Friday, even as it deepened the diplomatic problems confronting a British government struggling to forge closer ties to Washington without offending opinion at home.
The decision averted the risk of public protests that had threatened to embarrass both Mr. Trump and Britain’s prime minister, Theresa May, who has recently squirmed to distance herself from statements made by an American president seen by many Britons as deeply divisive.
The announcement, which came in a Twitter post by Mr. Trump that included a false jab at former President Barack Obama, is the latest reverberation from a hasty and ill-judged invitation made around a year ago, when Mr. Trump was offered, and accepted, a state visit to Britain. Such an honor is normally bestowed only much later in a presidency.
With Britain to leave the European Union in 2019, Mrs. May hopes to negotiate a new trade agreement with the United States, and the state visit was partly seen as a way of cementing ties with Mr. Trump.
But while Britons may pride themselves on their “special relationship” with the United States, that does not appear to extend to its president, whose statements on a range of topics have provoked widespread anger in the country. A petition calling for the invitation to be withdrawn was signed by more than 1.8 million people, the issue was debated in Parliament and, with large-scale protests threatened, the state visit plan was quietly put on the back burner.
Last year the United States ambassador to Britain, Woody Johnson, said that he hoped Mr. Trump would visit in early 2018 and dedicate the new embassy, providing the opportunity for a symbolically important, but lower-key, visit to a close ally.
No official statement had been made about the visit, and no formal invitation had been issued, although diplomats were known to be trying to organize a meeting, and the embassy opening was an obvious moment at which to do so.
Then, late on Thursday night, the president took to his favorite medium, Twitter, and announced that he had scrapped his trip because he was unhappy with the new building, and the decision to quit the old site in central London, which has been taken over by the Qatari royal family’s property company, which plans to convert it into a luxury hotel.
His critics in Britain gave that explanation little credence. Ed Miliband, the former Labour Party leader, responded to Mr. Trump’s announcement on Twitter, saying: “Nope. It’s because nobody wanted you to come. And you got the message.”
The old United States Embassy, in a historic square in the exclusive Mayfair neighborhood, was deemed to be vulnerable to terrorist attacks. The new one, which includes a small moat, is a high-tech construction in a former rail yard on the South Bank of the Thames.
Though Mr. Trump blamed the Obama administration for the move, the first announcement of new embassy site had been made in 2008 during the administration of President George W. Bush. On its website the United States Embassy says that “the new London Embassy is funded entirely from the proceeds of sale of U.S. government properties in London.”
In 2011 Adam Namm, then acting director of the Bureau of Overseas Buildings Operations, said the building would cost about $1 billion — “in the ballpark of the most expensive embassies we have built.”
In response to Mr. Trump’s statement, Britain’s foreign secretary, Boris Johnson, accused the opposition Labour Party’s leader, Jeremy Corbyn, and the London major, Sadiq Khan, of having endangered the trans-Atlantic relationship.
But the furor illustrates the extent to which any potential visit by Mr. Trump to Britain has become politically polarizing, even as the country’s establishment grapples with the question of whether to invite the president to the wedding of Prince Harry and the American actress Meghan Markle.
Mr. Trump visited several continental European countries last year, including France, where President Emmanuel Macron’s handling of his American counterpart appeared to make the British look fumbling.
“Macron treated Trump with respect and warmth on the one hand,” said Mark Leonard, director of the European Council on Foreign Relations, a research institute, “but on the other hand was principled in defense of French interests, and didn’t give an iota on the substance.”
By contrast, Mrs. May was “all over the place,” Mr. Leonard added.
“There was the attempt to rush over to the U.S. to embrace him, then she became implicated in the things he was doing, and then she had to pull back, so she’s been zigzagging,” he said.
“Britain then gets the worst of all worlds because it has confused everyone.”
While Mrs. May is keen to create closer ties with Washington, on many global issues her approach is more closely aligned with the positions of the European Union. She has expressed support both for the Paris climate change accord and the Iran nuclear deal, for example.
And at home, Mr. Trump’s statements have caused her problems. Last year Mr. Trump denounced Mr. Khan after his response to a bombing in June, misconstruing a call for calm as lack of concern about terrorist threats. And his tweets about a bombing in London in September suggested that the police had been monitoring attackers but had done nothing.
Mr. Trump’s retweets of a far-right group’s anti-Muslim videos in November stirred criticism from across the political spectrum in Britain, and prompted Mrs. May to criticize him.
Mr. Khan said the president’s Twitter postings made clear that Mrs. May had been mistaken to extend an invitation to Mr. Trump so quickly. “It appears that President Trump got the message from the many Londoners who love and admire America and Americans but find his policies and actions the polar opposite of our city’s values of inclusion, diversity and tolerance,” he said Friday in a Twitter post.
Mr. Trump’s most vocal supporter in Britain, Nigel Farage, former leader of the United Kingdom Independence Party, told the BBC that he regretted that the president would not be opening the embassy.
“It’s disappointing. He’s been to countries all over the world and yet he’s not been to the one with whom he’s closest. I would say it’s disappointing.
“But maybe, just maybe, Sadiq Khan, Jeremy Corbyn and the Labour Party planning mass protests, maybe those optics he didn’t like the look of,” Mr. Farage added.
Spurred on by the dispute, Madame Tussauds placed a statue of Mr. Trump outside the new embassy.
Yet there was no disguising the delight of some of Mr. Trump’s critics at the news. One opposition Labour Party lawmaker, David Lammy, wrote on Twitter: “Happy Friday everyone.”