BERLIN—The German government is leaning toward letting Huawei Technologies Co. participate in building the nation’s high-speed internet infrastructure, several German officials said, the latest sign of ambivalence among U.S. allies over Washington’s push to ostracize the Chinese tech giant as a national security risk.

A small group of ministries reached a preliminary agreement two weeks ago that still needs formal approval by the full cabinet and parliament, officials said. The final action isn’t expected for several weeks.

...