Despite doubts about Apple's iPhone business, the company scored a win Tuesday by surprising analysts with the smartphone's continuing appeal.

The tech giant reported $42.4 billion in revenue for its third quarter. Although that's a drop of 14.6 percent from the same period last year — the second quarter in a row that Apple's revenue has dropped — it beat analyst projections that the firm would report $42.09 billion in revenue. The company reported a quarterly profit of $7.8 billion, down 27 percent from the same time last year.

Concerns about iPhone sales dogged the company ahead of the earnings report, as analysts worried about slumping sales of its flagship phone. But Apple beat expectations on that front as well, reporting sales of 40.4 million iPhones, which slightly beat projections of 40 million. Profit on the iPhone was also down, probably because the company's latest model, the iPhone SE, isn't aimed at the very top end of the smartphone market.

“We are pleased to report third quarter results that reflect stronger customer demand and business performance than we anticipated at the start of the quarter,” Tim Cook, Apple’s chief executive, said in a statement.

The real growth category for Apple was its services, which grew 19 percent year-over-year; Cook said on the earnings call that Apple expects this business alone to be the same size as a Fortune 100 company next year. That could explain why Apple is focusing so heavily on the services and content portion of its business. On Tuesday, Variety reported that Apple has bought the exclusive rights to a series called "Carpool Karaoke," based off the popular celebrity singalong segment on "The Late Late Show with James Corden."

“The industry is pressuring Apple to reveal the next big source of growth beyond the iPhone, but the reality is that this is extremely unlikely to come from a single new product," said Geoff Blaber, vice president at the analysis firm CCS Insight. "Apple’s strength is its ecosystem and services revenue growth is the biggest indicator of its long-term health."

Apple said it expects revenue between $45.5 billion and $47.5 billion in its next quarter, which is slightly less than its guidance in the same period last year. Analysts say that Apple's new iPhone this fall will come with a few incremental changes and that the firm will wait until 2017 to release a major upgrade to its smartphone.

Still, the company's surprisingly strong results were enough to keep its shares up in after-hours trading. Shares closed at $96.67 per share and jumped as much as 7 percent in after-hours trading.

That's good news for Apple, particularly after its chief rival, Samsung, announced that its latest Galaxy S7 phones are selling so well that its profits should hit a two-year high when it reports earnings Thursday.

The smartphone market has seen growth slow for several quarters. In fact, 2017 could be the first in which the five largest technology categories — smartphones, tablets, computers, televisions and laptops — make up less than half of the industry's revenue, according to Consumer Technology Association economist Shawn DuBravac.

Yet sales of the iPad were also slightly above expectations with 10 million units sold, though they are still down from the same period last year. Apple sold 4.3 million Macs.

The question for Apple is whether its new ventures can grow quickly enough to compensate for shrinking revenue from the smartphone business, which makes up 56 percent of Apple's revenue. Pessimism about the company's ability to reclaim its former mantle of innovation will be hard to dispel.

"When we ask ourselves 'Do we see Apple gaining or losing its next $100 billion of value', the answer is losing," Colin Gillis, an analyst for BGC Partners, wrote in a Monday note. He has downgraded Apple's stock to "sell."