Apple is still running a well-oiled moneymaking machine despite cooling demand for its hottest product, the iPhone.

Sales and revenue in the July-September quarter exceeded Wall Street estimates as Apple’s newest iPhones got off to a better start than expected, even though the devices aren’t that much different from last year’s models.

“We concluded a groundbreaking fiscal 2019 with our highest Q4 revenue ever, fueled by accelerating growth from Services, Wearables and iPad,” said Tim Cook, Apple’s CEO, in a statement. “With customers and reviewers raving about the new generation of iPhones, today’s debut of new, noise-cancelling AirPods Pro, the hotly-anticipated arrival of Apple TV+ just two days away, and our best lineup of products and services ever, we’re very optimistic about what the holiday quarter has in store.”

Apple said Wednesday that revenue rose 2% from the same time last year to $64 billion, despite iPhone revenue dropping 9%. The company’s iPhone sales have now declined from the previous year for four straight quarter.

Apple’s quarterly profit dipped 3% to $13.7 billion, but its earnings per share of $3.03 topped analyst projections.

In another encouraging sign for the company, Apple’s sales in China recover further from a sharp drop-off earlier this year. That helped ease worries that Apple might be bruised by President Donald Trump’s trade war with the world’s most populous country.

Apple also signaled its confidence that the momentum will continue in the current quarter, which spans the crucial holiday season. The Cupertino, California, company projects revenue will climb by about 4% from the same time last year.

“Our strong business performance drove record Q4 EPS of $3.03 and record Q4 operating cash flow of $19.9 billion,” said Luca Maestri, Apple’s CFO, in the earnings announcement. “We also returned over $21 billion to shareholders, including almost $18 billion in share repurchases and $3.5 billion in dividends and equivalents, as we continue on our path to reaching a net cash neutral position over time.”

Part of that growth will likely come from a hotly anticipated video streaming service called Apple TV Plus. It’s scheduled to debut Friday to compete against industry pioneer Netflix and a slew of new entrants, including Disney Plus and HBO Max.

“You can tell from the guidance we are bullish,” Cook told analysts during a Wednesday conference call.

Add it all up, and it becomes easier to see why the stock market’s sentiments about Apple have changed dramatically since the company warned earlier this year that iPhone sales were falling, especially in China. That flop coming out of last year’s holiday season made it clear that the iPhone was losing some of its luster, raising fears that Apple’s best days may have past.

Those worries hammered Apple’s stock, driving down the price to $142 in early January.

But the stock has been setting new highs this month as investors began to realize Cook had crafted an effective strategy to counteract the waning demand for iPhones. The stock’s recovery translates to a nearly $500 billion swing in fortune for Apple’s shareholders as the company’s market value has soared back to $1.1 trillion — roughly the same level as its long-time rival, Microsoft.

Streaming wars intensify: Apple TV+ kicks off Friday; Disney+ comes next

Apple Inc. shares gained nearly 2% to $247.77 in Wednesday’s extended trading after the company revealed its fiscal fourth-quarter financial report.

Apple’s recent success has been driven largely by strong growth in its services division, which primarily feeds off the roughly 1.4 billion iPhones, iPads and iPod Touches already in use. The division already is prospering from app store commissions, device repairs, digital payments and Apple’s music-streaming service.

Services generated $46 billion in revenue during Apple’s just-ended fiscal year, accounting for 18% of the company’s revenue. Just three years ago, services accounted for 11% of Apple’s revenue.

And now it has another way to reel in more revenue from video streaming.

Apple is selling its streaming service for just $5 per month, less than half the price of Netflix’s most popular plan. It’s also giving it away for a year to anyone who buys an iPhone, iPad or Mac computer, an attempt to quickly amass tens of millions of subscribers. But many of those subscribers probably won’t be paying for the first year, meaning video service is unlikely to become a big cash cow out the gate.

The service also is only starting off with a handful of TV series, including one starring Jennifer Aniston and Reese Witherspoon. But Apple is promising to spend billions of dollars on other shows and movies as part of its effort to catch up with Netflix, which boasts 158 million subscribers.

Apple could still face another potential stumbling block if Trump follows through on recurring threats to impose a 10% tariff on about $300 billion worth of products imported from China that have so far been exempted from those taxes in his trade war.

Although it’s assembled in China, the iPhone has been among the goods insulated from the tariffs so far. But that could change Dec. 15 if Trump and China don’t negotiate a truce.