LONDON — Since becoming Britain’s prime minister six months ago, Boris Johnson has managed to strike a delicate balance in his relationship with President Trump, keeping him at a distance during Britain’s election while more recently showing sympathy for his pressure tactics against Iran.

On Tuesday, however, Mr. Johnson was confronted with a stark choice: In deciding to give the Chinese telecommunications giant, Huawei, limited access to Britain’s new high-speed broadband network, he broke abruptly with the president who once praised him as a “really good man” and a British version of himself.

That risks opening a rift between Mr. Johnson and Mr. Trump at the very moment Britain is leaving the European Union. It could also jeopardize efforts to negotiate a trans-Atlantic trade agreement that Mr. Johnson has promoted as one of the prizes of Britain’s newly independent status.

The Trump administration put heavy pressure on Mr. Johnson’s government to rule against Huawei, dispatching a high-level delegation to London two weeks ago to warn of the risks of opening up fifth-generation, or 5G, networks to a firm that they assert has ties to Chinese security agencies and the People’s Liberation Army.