As Britain prepares to cast off from the European Union, fears over the security of Huawei have forced Johnson to choose between global rivals the United States and China.
He had been under intense pressure from U.S. President Donald Trump, while Beijing had warned London, which has sought to court China in recent years, that billions in investment would be at risk if it sided with Washington.
Reversing a January decision to allow Huawei to supply up to 35% of the non-core 5G network, Johnson banned British telecoms operators from buying any 5G equipment from Huawei by year-end and gave them seven years to rip out existing gear.
"This has not been an easy decision, but it is the right one for the UK telecoms networks, for our national security and our economy, both now and indeed in the long run," digital minister Oliver Dowden told parliament.
"By the time of the next election, we will have implemented in law an irreversible path for the complete removal of Huawei equipment from our 5G networks".
The reason given for the about-turn was the impact of new U.S. sanctions on chip technology, which Britain's National Cyber Security Centre, part of the GCHQ eavesdropping agency, had told ministers meant Huawei was not a reliable supplier.
White House National Security Adviser Robert O'Brien said Britain's action reflected a growing consensus that Huawei and other untrusted vendors posed a threat to national security because they remained "beholden to the Chinese Communist Party".
According to a law introduced in 2017 under Chinese President Xi Jinping, Chinese companies have an obligation to support and cooperate in China's national intelligence work.
China's ambassador to Britain Liu Xiaoming called the decision "disappointing and wrong".
"It has become questionable whether the UK can provide an open, fair and non-discriminatory business environment for companies from other countries," he said.
The ban will delay the roll-out of 5G - cast as the nervous system of the future economy - by two to three years, and add costs of up to 2 billion pounds ($2.5 billion).
The Dec. 31, 2027 deadline was not as bad as British telecoms operators such as BT, Vodafone and Three had feared. They were concerned that they would be forced to spend billions of pounds to rip out Huawei equipment much faster.
BT said 500 million pounds already earmarked to comply with the earlier cap would cover its costs. Its shares closed up 4%.
5G PROXY WAR?
Hanging up on Huawei marks an end to what former Prime Minister David Cameron cast as a "golden era" of ties which saw Britain pushed as Europe's top destination for Chinese capital.
But London has been dismayed by a crackdown in Hong Kong and the perception China did not tell the whole truth over the novel coronavirus outbreak.
Huawei said the decision was more about U.S. trade policy than security. "It threatens to move Britain into the digital slow lane, push up bills and deepen the digital divide," a spokesman said.
In what some have compared to the Cold War antagonism with the Soviet Union, the United States is worried that 5G dominance could lead towards Chinese technological supremacy.
After Australia first raised alarms about the risk of 5G being hijacked by a hostile state, worries in the West about Huawei have mounted. https://www.reuters.com/investigates/special-report/huawei-usa-campaign
The United States calls the company an agent of the Chinese Communist state - a view widely supported in Johnson's Conservative Party. Huawei denies it spies for China and says the United States wants to frustrate its growth because no U.S. company offers the same technology at a competitive price.
In a tweet, U.S. Secretary of State Mike Pompeo said the British decision "advances Transatlantic security in the #5G era while protecting citizens' privacy, national security, and free-world values."
British ministers say the rise to global dominance of Huawei, founded in 1987 by a former People's Liberation Army engineer, has caught the West off-guard.
Dowden said Britain was working with its allies to foster stronger rivals to Huawei, naming firms from Finland, Sweden, South Korea and Japan.
"The first thing we need to do is ensure that we protect the other two vendors in this market, so Nokia, and Ericsson," Dowden said. "Secondly we need to get new suppliers in, that starts with Samsung, and it starts with NEC."
Nokia and Ericsson said they stood ready to replace Huawei gear.
By allowing Huawei's equipment to remain in the 5G network until end-2027 and in older mobile networks, Johnson stopped short of demands from some lawmakers for a ban in four years.
Chinese imports to Britain doubled in the 15 years to 2018, to about 9% of all goods imported, worth 43 billion pounds.
($1 = 0.7978 pounds)
(Additional reporting by William James and Steve Holland; Writing by Paul Sandle, Guy Faulconbridge and Michael Holden; Editing by William MacLean, Peter Graff and Catherine Evans)
By Paul Sandle and Guy Faulconbridge