Apple’s stock sours, Microsoft’s soars. Say what?!

FILE- In this May 7, 2018, file photo Microsoft CEO Satya Nadella looks on during a video as he delivers the keynote address at Build, the company's annual conference for software developers in Seattle. Microsoft is threatening to overtake Apple as the world’s most valuable publicly traded company. The market closed Tuesday, Nov. 27, with Microsoft just behind Apple. (AP Photo/Elaine Thompson, File)

It has nothing to do with posting selfies or finding a soul mate. The company is instead making billions of dollars selling cloud-computing and other technical services to offices around the world.

Say hello to Microsoft, the 1990s home-computing powerhouse that is having a renaissance moment – eclipsing Facebook, Google, Amazon and the other tech darlings of the late decade.

And now it is close to surpassing Apple as the world’s most valuable publicly traded company.

Yes, that Microsoft. As other tech giants stumble, its steady resilience is paying off.

That Microsoft is even close to eclipsing Apple — and did so briefly a few times this week — would have been unheard of just a few years ago.

But under CEO Satya Nadella, Microsoft has found stability by moving away from its flagship Windows operating system and focusing on cloud-computing services with long-term business contracts.

“They’ve finally turned the corner and have become a viable cloud player,” said Daniel Morgan, senior portfolio manager for Synovus Trust. “They’ve made a very strong transition away from the desktop.”

A brief period of trading Monday was the first time in more than eight years that Microsoft was worth more than Apple. Microsoft surpassed Apple again briefly Tuesday, before Apple closed on top with a market value of $827 billion, just 0.5 percent ahead of Microsoft’s $822 billion.

Apple has been the world’s most prosperous firm since claiming the top spot from Exxon Mobil earlier this decade. Microsoft hasn’t been at the top since the height of the dot-com boom in 2000.

Microsoft became a contender again in large part because Apple’s stock has fallen 25 percent since early October, while Microsoft hasn’t done any worse than the rest of the stock market. But the fact that it hasn’t done poorly is a reflection of its steady focus on business customers in recent years.

Just a few years ago, Microsoft’s prospects looked bleak. The company was dependent on licensing fees from the Windows operating system used in personal computers, but people were spending money instead on the latest smartphones. In 2013, PC sales plunged 10 percent to about 315 million, the worst year-to-year drop ever, according to research firms Gartner and IDC. It didn’t help that Microsoft’s effort to make PCs more like phones, Windows 8, was widely panned.

But a turnaround began when the Redmond, Washington, company promoted Nadella as CEO in 2014. He succeeded Microsoft’s longtime CEO, Steve Ballmer, who initially scoffed at the notion that people would be willing to pay $500 or more for Apple’s iPhones.

That bet paid off. Windows is now a dwindling fraction of Microsoft’s business. While the company still runs consumer-focused businesses such as Bing search and Xbox gaming, it has prioritized business-oriented services such as its Office line of email and other workplace software, as well as newer additions such as LinkedIn and Skype. But its biggest growth has happened in the cloud, particularly the cloud platform it calls Azure. Cloud computing now accounts for more than a quarter of Microsoft’s revenue, and Microsoft rivals Amazon as a leading provider of such services.

Being less reliant on consumer demand helped shield Microsoft from holiday season turbulence and U.S.-China trade war jitters affecting Apple and other tech companies.

President Donald Trump amplified those tariff concerns when he told The Wall Street Journal in a story published late Monday that new tariffs could affect iPhones and laptops imported from China.

The iPhone maker had already seen its stock fall after reporting a mixed bag of quarterly results earlier this month amid fears about how the technology industry will fare in the face of such threats as rising interest rates, increased government regulation and Trump’s escalating trade war with China.

Apple also spooked investors with an unexpected decision to stop disclosing how many iPhones it sells each quarter. That move has been widely interpreted as a sign that Apple foresees further declines in iPhone sales and is trying to mask that.

While smartphones caused the downturn in personal computers years ago, sales of smartphones themselves have now stalled. That’s partly because with fewer innovations from previous models, more people choose to hold on to the devices for longer periods before upgrading.

Morgan said Microsoft is outperforming its tech rivals in part because of what it’s not. It doesn’t face as much regulatory scrutiny as advertising-hungry Google and Facebook, which have attracted controversy over their data-harvesting practices. Unlike Netflix, it’s not on a hunt for a diminishing number of international subscribers. And while Amazon also has a strong cloud business, it’s still more dependent on online retail.