Apple, the maker of the iPhone X, exceeded Wall Street's expectations with its latest earnings, partly due to selling pricier mobile phones.
The company, based in Cupertino, California, said its average iPhone selling price hit $724 (£552), beating analysts' expectations of $694 (£529).
But it missed Wall Street's target on phone sales, selling 41.3 million units compared to forecasts of 41.8 million units.
"The lesson Apple's management has learned from the iPhoneX, is when you sell a smartphone for more than $1000 you can sell fewer units and still reap the financial benefits," analyst Thomas Forte from DA Davidson & Co told Reuters.
Third-quarter revenue rose 17% to $53.3bn (£40.6bn), beating forecasts of $52.34bn (£39.9bn). Apple posted earnings per share of $2.34 compared to Thomson Reuters estimate of $2.18.
After disappointing earnings from Facebook, Netflix and Twitter, Apple's reassuring numbers were welcomed in after-hours trading.
Its stock rose 3.8% to $197.49 (£150.5) to within touching distance of becoming the first US company to hit the $1tn valuation.
Analysts have learnt to look past Apple's third-quarter earnings to avoid any disappointment as consumers await the next iPhone upgrade, which is expected in September.
There is also a sense that the days of soar-away sales are behind the mobile phone industry and investors are now more focused on Apple's services business – which includes Apple Music, iCloud and Apple Pay – for future growth.
Its services business delivered revenue of $9.5bn (£7.2bn), including $236m (£179m) from its lawsuit with Samsung.
Chief executive Tim Cook has set the services business a target of delivering $14bn (£10.6bn) in revenue every quarter by 2020.
The company said it expects fourth-quarter revenue of between $60bn (£45.7bn) and $62bn (£47.2bn).
"We're thrilled to report Apple's best June quarter ever, and our fourth consecutive quarter of double-digit revenue growth," Cook said.
More from Business
"Our Q3 results were driven by continued strong sales of iPhone, services and wearables, and we are very excited about the products and services in our pipeline."
PetroChina, the world's fourth biggest oil company by revenue, was the first company to pass the $1tn mark in 2007. It is currently worth about $220bn (£167bn).