Apple on Tuesday delivered stronger-than-expected results in the just-ended quarter as growth from services helped offset weak iPhone sales, sparking a rally in shares of the tech giant.

Profit in the quarter ending in June fell 13 per cent from the year-ago period to $10 billion while overall revenues increased one per cent to a better-than-forecast $53.8 billion.

The results beat reined-in expectations of analysts, and Apple shares rose more than four per cent in after-hours trade.

As iPhone sales weakened, Apple has been shifting to earnings from digital content and services sold to the legions of fans of its devices.

“This was our biggest June quarter ever – driven by all-time record revenue from services, accelerating growth from wearables, strong performance from iPad and Mac and significant improvement in iPhone trends,” said Apple CEO Tim Cook.

Apple has more than 420 million paid subscriptions across its array of services and is confident that number will eclipse 500 million next year, according to chief financial officer Luca Maestri.

Apple has stopped reporting iPhone unit sales, but Cook said he saw a “strong customer response” to iPhone promotions and financing programmes.

Apple saw its sales improve in the crucial China market, which included a double-digit increase in services revenue driven by strong growth in the App Store there, according to the company.

The sale of iPhones in that country was boosted by government stimulus, pricing moves by Apple, and trade-in and financing programmes, Cook said.

“Each of our categories – iPhone, iPad, Mac, Wearables, Services – everything improved sequentially,” Cook said of Apple’s performance in China.

“So we couldn’t be happier with the results or the progress.”

Long the driver of Apple’s money-making machine, iPhone revenue overall was down 12 per cent from last year to $26 billion.