Apple is back on top in the smartphone wars with a razor-thin lead

Tim Cook, CEO of Apple introduces the new iPhone 7
Mark Neuling | CNBC

Apple pulled ahead of Samsung as the world's top smartphone vendor for the first time in eight quarters, shipping the most smartphones in the crucial holiday shopping season, according to new data from Gartner. But the lead is razor thin.

Apple shipped about 77.04 million smartphones in the fourth quarter, Gartner estimated, just ahead of the 76.78 million shipped by Samsung. That means Apple has 17.9 percent of the global smartphone market share, narrowly above Samsung's 17.8 percent. It's the smallest difference Gartner has recorded.

This time last year, Samsung had nearly 21 percent of the market — but the massive global recall of its Galaxy Note 7 device slowed down sales in the third and fourth quarters, said Gartner research director Anshul Gupta.

Samsung, unlike Apple, has a wide range of high- and low-end phones and has used that variety to dominate the global market. Now that Apple has had better-than-expected sales of the high-end iPhone 7 Plus, the companies are closer than ever, separated by 256,000 units, according to Gartner.

The data square with research from other firms that track the industry, like Counterpoint Research.

Apple and Samsung face mounting competition from Chinese smartphone brands Huawei, Oppo and BBK, which grew their collective share by 7 percentage points in the fourth quarter, according to Gartner.

"Huawei is poised to reduce the gap further with the No. 2 global smartphone vendor," Gupta said.

Huawei shipped about 40.8 million phones in the fourth quarter, according to Gartner, and announced a U.S. launch in January. Huawei hopes the launch will propel it to No. 2 within two years, Richard Yu, director and CEO of Huawei's consumer business group, has said.