A decade ago, Microsoft looked like a dinosaur – heading for inevitable extinction as it failed to adapt to a fast-changing market.
But last week, as Wall Street chalked up big gains for the day, it reclaimed its position as the biggest company in the world for the first time in 15 years. Its market value jumped to US$850 billion ($1.2 trillion), putting it slightly ahead of both Apple and Amazon at the close.
Sure, its two biggest rivals were hammered in the recent technology sell-off. But it is also a signal of the way it has reinvented itself.
In fact, the business Bill Gates founded more than four decades ago has completed a remarkable comeback, with lessons for other companies, such as: manage the succession process, ditch sacred cows and acquire well.
Microsoft had done brilliantly from the rise of the desktop personal computer, and its control of the core operating system of the first great wave of technology made it a formidable beast.
But from the start of the new century, it floundered. It was wrong-footed by the rise of Google in search, and its own offerings – anyone remember Bing? – quickly slipped into obscurity. The rise of the smartphone was even more of a shock, with both Apple and Google's Android quickly dominating the emerging app economy.
For a while, it appeared as if Microsoft thought all we should do is tap away on Windows 95 and leave it at that. Anything more creative to do with microchips completely passed it by.
Even its founders seemed to have lost interest.
Gates concentrated on charity work, Paul Allen concentrated on sports and a space project until his death last month, while Steve Ballmer, its first business manager, and the driving force behind its global expansion in the Eighties and Nineties, left the company in 2014.
It surrendered the title of world's biggest company way back in 2003, and showed little sign of reclaiming it.
And yet, the past five years have witnessed a remarkable resurrection. Sales and profits are starting to rise again. The shares have almost tripled, rising from US$40 in 2014 to US$110 now.
It has downplayed older products, stopped trying to copy Apple and the rest of the tech whizz kids, and concentrated on reinventing itself for a changed technological landscape.
So what are the lessons that other companies can learn from the remarkable resurrection of the software company?
First, manage the succession. Gates was the founding visionary and carried on personally writing code up until the late Eighties. He could have carried on running the company personally into his 80s, but it is unlikely he would still have the drive and ambition and ideas to compete with the likes of Uber and Airbnb.
These days, he is listed as simply a "technology adviser", and his personal shareholding is down to less than 2 per cent. It has been a dignified, graceful exit from a company that he must still care passionately about but probably doesn't have a lot to add to any more.
His long-term sidekick Ballmer – crowned the "worst CEO in the US" by Forbes after a series of poor judgments – likewise had the good sense to step aside in 2014 before he could mess things up any more.
In fact, different individuals are right for different stages of the evolution of a business, and while Gates was great at starting it, and Ballmer at expanding it, neither was the right man to reinvent it.
The one thing they both got right was to allow Satya Nadella, who took over as chief executive in 2014, the space to reimagine the company from the ground up.
Next, ditch sacred cows. Since taking over, Nadella, who is rapidly emerging as one of the smartest business leaders in the world, has stopped trying to control operating systems.
For more than a decade, Microsoft was mainly interested in protecting its massive revenues from Windows and Office even at the cost of sacrificing potential opportunities elsewhere.
Nadella has swept all of that away. While those remain core products, and may well remain so for a long time to come, the real growth is now coming from cloud computing and business services.
In fact, with the exception of the Xbox, Microsoft was possibly the most rubbish consumer electronics manufacturer of all time, but in business services, it is a world-beater.
Nadella's trick has been to recognise what its real strengths are and how it can build on them.
Lastly, acquire well. The US$26b that Microsoft paid for LinkedIn in 2016 looked like a lot of money at the time, and Nadella took a lot of flak for it, but it increasingly looks like a masterstroke. The unit is growing at more than 30 per cent a year and, more importantly, cements Microsoft's position in the business market where the social network for professionals is dominant.
It has also bought GitHub, where developers share code, and Minecraft. By contrast, the last acquisition of the old era was the US$7b purchase of Nokia's mobile phone business (less said, the better).
Acquiring businesses is one of the hardest things to do well. There are a lot more failures than successes – but the hits can be very, very important and Microsoft has started getting them right.
True, Apple and Amazon both have formidable strengths and are in faster-growing markets. From cars to healthcare to voice computing, they are perfectly capable of coming up with something daring and world-beating.
But Microsoft shows us that even in technology, every story has a second or third chapter.
And no company has to accept gentle decline. From retailers to car manufacturers to broadcasters and publishers, there are lots of big British and European companies facing rapid technological change and near impossible challenges.
And yet, with the right strategies they can put themselves back on top again – and they can be reminded of that every time they log back into Office to fire up the next PowerPoint presentation.