Apple (AAPL - Get Report) shares traded at the highest level in nine months Wednesday after the tech giant shrugged off a slide in iPhone sales to produce better-than-expected second quarter earnings and a robust outlook into the final months of its financial year.

Apple said diluted earnings for the three months ending in June, its fiscal third quarter, came in at $2.18 per share, well ahead of the Street consensus forecast of $2.10 per shares, as overall revenues rose 1% from last year to a better-than-forecast $53.8 billion. 

Apple said iPhone revenues fell 12% from the same period last year to $26 billion, as customers held onto older phones for longer periods, while services revenues rose by more than 15% on a comparable basis to a record $11.5 billion, thanks to double-digit growth from the App Store, Apple Music, cloud services, and AppleCare.

Looking into the current quarter, the final of Apple's financial year, the company sees overall revenues of between $61 billion and $64 billion,  gross margins of between 37.5% and 38.5% and operating expenses of between $8.7 billion and $8.8 billion.

"We saw significant improvement in year-over-year iPhone performance compared to last quarter, very strong performances for both Mac and iPad and absolutely blowout quarter for Wearables, but we had accelerating growth of well over 50% and a new high watermark for services, where we set an all time revenue record of $11.5 billion," Apple CEO Tim Cook told investors on a conference call late Tuesday. "We accomplished these results despite strong headwinds from foreign exchange which impacted our top-line growth rate  ... importantly, in constant currency, our revenue grew in all five of our geographic segments."

"On so many fronts there's an enormous amount to look forward to over the next few months, including the launch of new services like Apple Arcade, Apple TV+, and Apple Card," he added. "And without giving too much away, we have several new products that we can't wait to share with you."

Apple shares were marked 5.8% higher Wednesday to change hands at $220.94 each, the highest since November 1 and a move that would extend the stock's year-to-date gain to around 37.6% and value the Cupertino, California-based tech giant at just over $1 trillion.

Apple CFO Luca Maestri said overall product revenue fell 2% from last year to $42.4 billion, with the slowing rate of iPhone sales offset by an 11% increase in Mac revenues to $5.8 billion an an 8% bump in iPad sales to $5 billion. 

"Wearables, home and accessories revenue accelerated across all our geographic segments, growing 48% to over $5.5 billion and setting a June quarter record," Maestri said. "This growth was fueled primarily by the strong performance of our wearables business, which was up well over 50% and has become the size of a Fortune 200 company over the last 12 months."

"In addition, we generated double-digit revenue growth from Apple TV and accessories during the quarter," he added.