Huawei Technologies Co. took the top spot in China’s smartphone market for the first time in more than four years, a comeback fueled by new designs and software that appealed to users in a slowing market.

The hardware giant held on to a roughly 18% share of the market in the June quarter, while other leading competitors like Vivo and Oppo slumped, according to IDC data. The Shenzhen device maker showed greater resilience than rivals as overall shipments in China fell 4% to 69 million units.