Despite reporting better-than-expected iPhone sales, Apple’s latest earnings missed Wall Street estimates for the first time in four years, reporting a quarterly revenue decline for the first time in 13 years and driving shares in the world’s most valuable company down as much as 6 percent in after-hours trading.

Apple reported revenue of $50.56 billion for the three months to the end of March, which represented a 13 percent drop compared with the $58 billion it earned in the same period last year. Profits were down even further, with the $10.5 billion significantly down on the $13.6 billion it reported last year — a drop of 23 percent. Earnings per share came in at $1.90 per diluted share, which again was down on the $2.33 reported last year.

The consensus among Wall Street analysts polled by Thomson Reuters before the results were announced was for Apple to report revenue of $52 billion earnings per share of $2.

Apple has also issued guidance for the current quarter, which is lighter than analysts had predicted, estimating revenue of between $41 billion and $43 billion and gross margin of between 37.5 percent and 38 percent. This compares with revenue of $49.6 billion and a gross margin of 39.7 percent in the same period last year.

CEO Tim Cook, in an earnings call with analysts, called the quarter “very busy and challenging,” pointing to highlights like strong growth in services (iTunes, App Store and Apple Pay) which outperformed the company’s Mac business for the first time.

The most significant decline came in Apple’s iPhone business, which made up 65 percent of Apple’s overall revenue for the quarter. In the first three months of 2016 the company sold 51.2 million iPhones, well below the 61 million it sold in the same period last year but was ahead of Wall Street analysts’ prediction of 50 million units sold.

Cook, however, called the iPhone business “healthy and strong,” pointing to strong conversion of Android users to the iPhone and sales of iPhones in India up 56 percent year on year — though according to figures from Counterpoint Research, Apple still holds just 2 percent of the market in the subcontinent.

“Despite weak guidance, which we attribute to a pause ahead of the iPhone 7 launch and soft iPhone 6s cycle, we see the June quarter as the trough,” Angelo Zino, equity analyst at S&P Global Market Intelligence, said in a research note.

Apple is being affected by an overall slowdown in demand for smartphones globally, with IDC predicting growth in the market will decline to almost half what it saw in 2015, with slowdown in China — a market where Apple has seen huge growth in the last two years — being particularly significant. Apple’s revenue in greater China dropped year-on-year but Apple’s CFO Luca Maestri said its performance in China “was better than the figures suggested.”

Elsewhere, Apple’s iPad line continued to decline despite the introduction of new models with the company selling 10.3 million units during the quarter, down from the 12.6 million units it sold in the same period last year. While the number of iPad users continues to increase, it is a competitive marketplace and Apple has been losing share of the U.S. tablet market. After falling below 50 percent for the first time in 2015, Apple’s share of the tablet market is expected to drop to 47.8 percent in 2016 according to eMarketer and by 2020 the market research firm estimates that figure will drop to 44 percent.

“Clearly, this was a bit of an ugly quarter for Apple,” Jan Dawson, chief analyst with Jackdaw Research, told International Business Times. “We knew iPhone sales were going to be down year on year for the first time ever, but the problems went beyond that, with all three major product lines in decline, and nothing else coming anywhere near making up the difference.”

Apple’s Mac division, which has consistently outperformed the falling PC market in recent years, reported sales of 4 million units, down from 4.5 million units in the same period last year and down from 5.3 million in the last quarter. Overall the PC market saw a drop of almost 10 percent in the first three months of 2016, according to figures from Gartner.