(Reuters) – Apple sold more iPhones than Wall Street expected in the third quarter and forecast revenue in the current period would top many analysts’ targets, soothing fears that demand for Apple’s most important product had hit a wall.
Its shares (aapl) rose almost 7% in after-hours trading.
The world’s most valuable publicly traded company said it sold 40.4 million iPhones in the third quarter, down 15% from the year-ago quarter but slightly more than the average analyst forecast of 40.02 million, according to research firm FactSet StreetAccount.
IPhone sales dropped for the second straight quarter, and Apple’s total revenue fell 14.6% in the fiscal third quarter, ended June 25.
Demand for Apple’s phones has waned in China, partly because of economic uncertainty there, and has also slowed in more mature markets as people tend to hold on to their phones for longer.
Apple Chief Financial Officer Luca Maestri said the company’s performance had topped his expectations in a quarter weighed down by tough foreign exchange rates and difficult comparisons with blockbuster iPhone 6 sales from the previous year.
Apple reduced channel inventory by $3.6 billion, exceeding the $2 billion expected reduction, meaning sales were better than they appeared, Maestri said.
Customer demand “was better than what is implied in our results and better than we had anticipated,” he told Reuters in an interview.
Sales of the iPhone fell last quarter for the first time since the gadget’s release in 2007, dropping 16.3%. Maestri projected the gadget’s average selling price to rise in the September quarter.
Sales of iPhones account for about two-thirds of Apple’s total sales. The iPhone lineup includes the iPhone 6S and 6S Plus, as well as the smaller and cheaper iPhone SE.
Apple’s quarterly net profit fell 27% to $7.8 billion, while revenue of $42.36 billion beat analysts’ average estimate of $42.09 billion, according to Thomson Reuters I/B/E/S.
Sales in Greater China, once touted as Apple’s next growth engine, decreased 33.1%, compared with a 112.4% growth in the year earlier quarter and a near 26% fall in the second quarter.
Investors are sensitive to any signs of trouble in China, one of the company’s largest markets by revenue.
Maestri attributed the drop to channel inventory reduction in the nation, foreign exchange headwinds and a general downturn in the Chinese economy.
“It is very clear that there are some signs of economic slowdown in China, and we will have to work through them,” he said. “We understand China well and we remain very, very optimistic about the future there.”
Apple’s services business, which includes the App Store, Apple Pay, iCloud and other services generated nearly $6 billion in revenue, up 18.9% from the previous year.
As iPhone sales level off, Apple is attempting to wring more revenue out of its existing base of users by emphasizing services such as the App Store, Apple Music, storage center iCloud and mobile wallet Apple Pay. Such services emerged as Apple’s second-largest business after the iPhone for the first time in the company’s second quarter, eclipsing gadgets such as the iPad and the Mac.
That shift in the business bodes well for Apple because gross margins on services are better than the average for the rest of the company, Maestri said.
“It’s a great business because it is recurring in nature and more linked to our installed base,” he said.
The company forecast fourth-quarter revenue of $45.5 billion to $47.5 billion, largely above Wall Street’s average estimate of $45.71 billion, according to Thomson Reuters I/B/E/S.
For more about Apple, watch:
The forecast, covering the quarter ending September, will likely include at least the first weekend of sales of the iPhone 7 range, which Apple is expected to launch in September.
Up to Tuesday’s close, Apple’s shares had fallen about 8.2% since the start of the year. Shares rose almost 7% to $103.10 in after-hours trade following publication of results.
Correction: July 26, 2016 (5 pm): An original version of this article incorrectly reported that Apple’s fourth quarter forecast was below analyst expectations. In fact, it was higher. This story was also updated with additional information throughout.