Sales of Apple's iPhones fell at their steepest-ever rate, according to data for the three months to the end of March.
The firm said revenue from the iPhone dropped by 17%, compared with the same period a year earlier, to $31bn.
However, Apple chief executive Tim Cook said sales were stronger towards the end of March, including in China where it cut iPhone prices to boost demand.
Apple lifted its outlook for the three months to June.
That sent shares more than 5% higher in after-hours trading.
The company had warned of slowing iPhone sales earlier this year, especially in China, where Apple competes with cheaper rivals such as Huawei Technologies and Xiaomi.
But Mr Cook said price adjustments in China, lower Chinese taxes on the iPhone and new trade-in and financing deals helped sales start to recover toward the end of the quarter.
He also credited improving demand for products such as the Apple Watch, along with progress in US-China trade talks.
"The trade relationship, versus the previous quarter, is better. The tone is better," Mr Cook told Reuters. "The sum of all of this together, it helped us."
Apple has lifted its guidance for its third quarter revenue to between $52.5bn and $54.5bn.
For the three months to March, total sales hit $58bn compared to analysts' estimates of $57.3bn.
However, that is below total sales of $61.1bn in the second quarter last year. And while demand improved in China, sales in the region were still down by 20%.
Profits for the second quarter fell to $11.5bn compared to $13.8bn in the same period a year ago.
Apple is attempting to shift its reliance on the iPhone towards services and last month unveiled its new TV streaming platform, Apple TV+, to take on the likes of more established companies such as Netflix.
Services revenue rose to $11.4bn from $9.8bn in the same quarter last year.
But Yoram Wurmser, principal analyst at eMarketer, said long-term growth in services and, to a less extent, other devices "depend on having as many users as possible in the Apple ecosystem, and that's still primarily about the iPhone".
"The long-term growth of the company still depends directly and indirectly on iPhone sales," he added.