The tech giant sold 45.51 million iPhones in the three months to 24 September, beating an average estimate of 44.8 million.
The company also forecast higher-than-expected holiday season revenue of between $76bn and $78bn.
But revenue in the fourth quarter fell 9% to $46.85bn.
That meant annual revenue fell for the first time since 2001, highlighting a slowdown in the smartphone market as well as intensifying competition, particularly from Chinese rivals.
Analysis: Rory Cellan-Jones, BBC Technology correspondent
It was no surprise that Apple saw its first fall in annual revenues for 15 years. It became apparent earlier in the year that sales of the iPhone - surely the most profitable product in history - had plateaued and they continued to disappoint this quarter. It was hard to spot any product or market delivering outstanding results - the fact that Apple still hasn't released any figures for its Watch tells its own story - and the 30% fall in China sales looked particularly worrying.
But somehow Apple's Chief Executive Tim Cook still managed to paint a rosy picture. He pointed to the 24% rise in income from services like Apple Music and Apple Pay. He told us that he was thrilled with the response of customers to the iPhone 7 - and that round the world, including in China, demand was outstripping supply.
And crucially he looked forward to a return to growth in the next quarter, with Apple forecasting a record-breaking holiday season. Investors have been looking for reasons to buy back into Apple and that prediction may help continue the recent upward path of the shares.
But the technology crowd is still waiting for some radical new innovation, to prove the company founded by Steve Jobs hasn't lost its creative spark. Tim Cook wouldn't be drawn when quizzed about moves into TV or building a car or a connected speaker like the Amazon Echo. He did say "we have the strongest product pipeline we've ever had". But that is a line we have been hearing for some time.
Apple executives said demand for the new iPhone 7 was strong, despite fiscal fourth-quarter revenue falls in China and the Americas, its two most important markets.
Revenue from Greater China, once seen as Apple's next growth hope, fell 30% in the quarter, after dropping 33% in the previous quarter.
In the same period last year, revenue from Greater China doubled.
Apple's shares were down 3% at about $114.80 in after-hours trading.
"Apple didn't have a great [fourth quarter] as iPhones, Macs, China, the US and what appears to be Watch were down," said Patrick Moorhead, an analyst at Moor Insights & Strategy.
Net income fell to $9.01bn in the fourth quarter, down from $11bn in the same quarter last year.
For the year, net income fell to $45.7bn from $53.4bn.
Chief Financial Officer Luca Maestri said it was "impossible to know" if there was any effect yet from rival Samsung halting production of Galaxy Note 7 phones earlier this month.
Apple has reported its third quarter in a row of falling iPhone sales and revenue, but sales beat analyst expectations.