According to a new report from IDC, Apple once again overtook Samsung as the top smartphone company during the final quarter of last year. The Korean firm led the way for the first three quarters of 2017, but the release of the iPhone 8, 8 Plus, and X helped push Cupertino into first place. The data also shows that global smartphone shipments fell 6.3 percent compared to the same period last year.

Apple might be experiencing mixed emotions right now. An earlier report from Canalys states that while the iPhone X was the best-shipping smartphone over the holidays (29 million units), it still fell below expectations. This was followed by reports that Apple would be slashing production of its flagship handset in half due to weaker-than-anticipated sales.

However, the company just posted record quarterly earnings of $88.3 billion, up 16 percent YoY. Tim Cook said growth included the highest revenue ever from a new iPhone lineup, and that the iPhone X has been Apple’s top-selling iPhone every week since it shipped in November—the company doesn’t give sales breakdowns of its individual handsets.

According to IDC, 403.5 million smartphones were shipped in the fourth quarter, 6.3 percent fewer than the 430.7 million that were shipped in Q4 2016. Apple’s phones accounted for 77.3 million of these, giving it a 19.2 percent market share, putting it ahead of Samsung, which shipped 74.1 million units and took an 18.4 percent share.

Despite taking the lead, Apple saw a 1.3 percent fall in shipments compared to a year earlier, but it wasn’t as bad as the 4.4 percent decrease suffered by Samsung. The only company in the top five that didn’t experience a drop was Xiaomi. The Chinese firm shipped almost 97 percent more handsets (28.1 million) in Q4 2017 than in Q4 2016 (14.3 million).

Vendor Q4 2017 Shipment Volumes Q4 2017 Market Share Q4 2016 Shipment Volumes Q4 2016 Market Share Year-Over-Year Change
Apple 77.3 19.2% 78.3 18.2% -1.3%
Samsung 74.1 18.4% 77.5 18.0% -4.4%
Huawei 41.0 10.2% 45.4 10.5% -9.7%
Xiaomi 28.1 7.0% 14.3 3.3% 96.9%
Oppo 27.4 6.8% 31.6 7.3% -13.2%
Others 151.3 38.6% 183.7 42.7% -17.6%
Total 403.5 100.0% 430.7 100.0% -6.3%

Along with the other two Chinese giants—Huawei and Oppo—Xiaomi retained its position in the top five last quarter.

Looking at the figures for the year, it’s Samsung that sits on top, having shipped over 100 million more units than second-place Apple. Xiaomi, meanwhile, replaced Vivo as the fifth-largest smartphone maker. Yearly global shipments are down, though only by 0.1 percent.

Vendor 2017 Shipment Volumes 2017 Market Share 2016 Shipment Volumes 2016 Market Share Year-Over-Year Change
Samsung 317.3 21.6% 311.4 21.1% 1.9%
Apple 215.8 14.7% 215.4 14.6% 0.2%
Huawei 153.1 10.4% 139.3 9.5% 9.9%
Oppo 111.8 7.6% 99.8 6.8% 12.0%
Xiaomi 92.4 6.3% 53.0 3.6% 74.5%
Others 577.7 39.5% 654.5 44.4% -11.7%
Total 1472.4 100.0% 1473.4 100.0% -0.1%

"Many high-profile companies offered their widest product portfolio ever in hopes of capturing a greater audience. Meanwhile, brands outside the top 5 struggled to maintain momentum as value brands such as Honor, Vivo, Xiaomi, and OPPO offered incredible competition at the low end, and brands like Apple, Samsung, and Huawei maintained their stronghold on the high end," said Jitesh Ubrani, Senior Research Analyst, IDC.