Huawei just reached a major milestone, passing Apple to become the world's second largest smartphone seller.

The Chinese smartphone maker sold around 54 million phones last quarter, up more than 40% compared to the same period last year, according to research firms IDC, Canalys and IHS Markit.

That was enough to not only beat Apple (AAPL), but also narrow the gap with market leader Samsung (SSNLF). Samsung sold more than 70 million phones last quarter, down about 10% from the same time last year.

"The continued growth of Huawei is impressive, to say the least, as is its ability to move into markets where, until recently, the brand was largely unknown," IDC analyst Ryan Reith said in a statement.

Related: Huawei profits jump 28%

Huawei has leaped into second place despite being virtually locked out of the world's biggest economy.

The Chinese smartphone and telecom equipment maker has struggled to gain a toehold in the United States, mainly because of official concerns that its technology could be used by the Chinese government to gather intelligence.

Huawei has repeatedly denied that its products pose security risks.

Earlier this year it failed to clinch its first partnership with a major US carrier, after talks with AT&T fizzled out at the last minute. Having the backing of a wireless carrier is key to making inroads in the United States.

CNN is part of WarnerMedia, which is owned by AT&T.

"Despite its failure to strike a US carrier partnership ... the company has turned around quickly, moving away from its drive for profitability and focusing instead on finding volume growth at the low end," Mo Jia, an analyst with Canalys, said in a statement.

Related: UK security officials warn of 'new risks' from Huawei

Selling millions of cheap phones has worked well for Huawei in the Asia Pacific region, where its sales more than doubled compared with the same quarter last year, according to IHS Markit. It also experienced strong growth in Europe, the Middle East and Africa.

The success in its smartphone division comes as Huawei faces significant headwinds in its telecommunications business. Following the United States, security officials in the UK, Australia and Canada have in recent months warned of potential national security risks from using the Chinese firm's telecom equipment.

Huawei is one of several companies racing to develop capabilities for 5G, the next generation of wireless technology.

If major countries refuse or ban the use of Huawei's telecom gear, it would significantly handicap the company's ambition to become a global leader in 5G technology.