Spy chiefs from the West’s most powerful intelligence alliance agreed in a July meeting in Canada they needed to contain Huawei Technologies Co., according to people familiar with the matter, punctuating years of worry about the Chinese maker of telecommunications equipment.

Soon afterward, in an unprecedented campaign, some of the chiefs began to speak out publicly about the risks associated with Chinese-made gear, especially to next-generation 5G mobile networks now starting to be rolled out world-wide.

The...