By Julia Love and Anya George Tharakan

(Reuters) - Apple Inc <AAPL.O> sold more iPhones than Wall Street expected in the third quarter and estimated its revenue in the current period would top many analysts' targets, soothing fears that demand for the company's most important product had hit a wall.

Its shares rose 7 percent 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 percent 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, pushing down Apple's total revenue 14.6 percent 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. The sales slump has stoked concerns about whether the tech leader can continue to deliver profits at the level Wall Street has come to expect.

"China was a major letdown," said Patrick Moorhead, an analyst at Moor Insights & Strategy. "Samsung and Huawei are much more competitive now than a year ago and the Chinese economy is not doing well at all."

Moorhead said, however, that increased services revenue - which includes the App Store and iCloud - was a "very big bright spot for Apple."

Chief Financial Officer Luca Maestri told Reuters in an interview that Apple'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 said.

Sales of the iPhone fell last quarter for the first time since the gadget's release in 2007, dropping 16.3 percent. Maestri projected the gadget's average selling price to rise in the September quarter.

The iPhone drives about two-thirds of Apple's total sales. Apple Chief Executive Tim Cook said during a call with analysts that the iPhone SE, a cheaper, four-inch (10 cm) phone released this year, was extending the range of people able to buy Apple phones.

"It's opening the door to customers we weren't reaching before," he said.

Apple's quarterly net profit fell 27 percent 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.

CHINA WORRIES

Sales in Greater China, once touted as Apple's next growth engine, decreased 33.1 percent, compared with a 112.4 percent growth in the year-earlier quarter and a near 26 percent fall in the second quarter.

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.

Adding to Apple's woes in China, the company's stores for books and movies went dark earlier this year. Cook said Apple was working with regulators to restore the services but played down the financial impact of the outage, saying the stores yielded less than $1 million in revenue during the short time they were on the market.

"It’s not a revenue-related issue," he said. "This is a service we want to provide our customers."

Apple's services business, which includes the App Store, Apple Pay, iCloud and other services, generated nearly $6 billion in revenue, up 18.9 percent from the previous year.

As iPhone sales level off, Apple is attempting to use such services to wring more revenue out of its existing base of users. The business emerged as Apple’s second largest after the iPhone for the first time in the second quarter, eclipsing gadgets such as the iPad and the Mac.

That shift 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.

Maestri touted music as an example of one successful service, saying the growth of the Apple Music streaming service had more than made up for declines in digital downloads. To redouble its momentum in music, Apple purchased rights to the next season of popular series Carpool Karaoke, CBS Television Studios announced on Tuesday.

Apple 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.

The forecast, covering the quarter ending in 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 percent since the start of the year. Shares rose 7 percent to $103.47 in after-hours trade following publication of results.

(Reporting by Anya George Tharakan in Bengaluru and Julia Love in San Francisco; Editing by Savio D'Souza and Bill Rigby)