Microsoft is back at the top of the technology world following an extraordinary comeback to close the gap with Apple, some three years into a transformation of the onetime leader by chief executive Satya Nadella.
Microsoft regained its title as the world's most valuable company when it closed Friday at a higher market value than Apple for the first time since 2010, after a brief move ahead of the iPhone maker earlier in the week.
At Friday's close, Microsoft's market capitalisation was $851.2 billion, having tripled in value since Nadella took over in early 2014.
In the 1990s, Microsoft held the crown as the top tech firm and most valuable company as it powered the revolution in personal computers with its Windows operating system.
But in recent years, it appeared headed to obscurity after spectacular failures in mobile computing, while Apple, Google and Amazon saw their fortunes rise.
Analysts say patience, diversification and the willingness to jettison failing ventures helped fuel Microsoft's surge.
"Microsoft is firing on all cylinders right now," said Jack Gold, technology analyst with J. Gold Associates.
"Satya Nadella has been doing a fantastic job in leading them away from dead-end areas and being more innovative."
Thriving in the cloud
Microsoft still draws considerable revenue from Windows, the software that powers the vast majority of PCs.
But it has leveraged its position to bring business customers to its cloud computing platform known as Azure, and has developed a steadier revenue stream from its Office software suite for both consumers and enterprises.
"Azure has been really big for Microsoft," Gold said.
For companies already using Microsoft systems for PCs and servers, "it's easy for them to stick with Microsoft, and that's the advantage for Microsoft."
Microsoft has become far less dependent on a single product than in the past, with strong growth from its cloud services and revenues from its Xbox gaming business, Bing search, Surface tablets and PCs, as well as the professional social network LinkedIn acquired in 2016.
It won a $480 million contract with the US Army last month to supply HoloLens devices that will help troops train using augmented and virtual reality.
It is also competing with Amazon and others for a multibillion-dollar contract for Pentagon cloud services.
The diversified revenue stream is in contrast with Apple, which still relies on iPhone sales for the vast majority of revenue and profit.
"Microsoft is pretty well-balanced across a number of different categories," said Bob O'Donnell of TECHnalysis Research.
"For Apple, we've reached peak smartphone and it's a very challenging market. Longtime observers of Apple knew this would happen at some point, and the question is how quickly they can transition to services."
Microsoft's emphasis on business services makes the company less visible to consumers, but "it means they are not subject to the whims of tech fashion, and their revenue base is more solid and more stable," O'Donnell said.
Learning from failure
A big part of Microsoft's transformation came when it decided to throw in the towel on its Windows mobile phone business after acquiring the device business of Nokia but failing to get a foothold in the sector dominated by Apple and Google-powered Android smartphones.
"I think Satya Nadella exercised extraordinarily good judgment," said Roger Kay, a consultant and analyst at Endpoint Technologies Associates.
"He ceded the consumer business to Apple and focused on the corporate sector and the cloud."
Microsoft's failures in mobile may have actually helped it by forcing the company to work with rival operating systems, analysts say.
Apple, meanwhile, has largely required its own devices for its services, a strategy which Gold called "troubling."
"That's the same path Microsoft went down a decade ago," he said. "Apple is going to have to change that."
The company appeared to move a step toward opening its services in the past week, agreeing to offer its streaming music on Amazon's Alexa-powered devices.
"Apple has a great track record when it comes to reinvention," said a research note from Gene Munster and Will Thompson of the investment firm Loup Ventures.
It anticipated that the company's "next reinvention does not involve product replacement; rather, it will require a shift in mindset to consuming Apple products as a service."