When Satya Nadella took charge of Microsoft four years ago, the company was hardly on its knees. But the software giant, responsible for Windows, Office and Internet Explorer, had undoubtedly lost its way.
Nadella's predecessor Steve Ballmer, in one of his last acts as chief executive, pushed through the €5.4 billion ($9.1b) acquisition of Nokia's mobile phone business, in a desperate attempt to take on its old rival Apple.
The deal was announced after Ballmer had already revealed plans to retire. It looked very much like a parting shot, a combination of two businesses past their prime and who had lost their way in the iPhone era. Ballmer, a supercharged, highly-competitive brawler, had inherited the chief executive's seat from Bill Gates 13 years earlier, when Microsoft was on top of the world.
"Because of the success we had, we felt that we were the know-it-alls, [that] we were just great," Nadella says. "Except none of that was true. We had a successful business, we had successful products, but that doesn't necessarily make you a perpetual great. I think that is when you go from confidence to hubris, and that's brought down everybody, from empires in Ancient Greece to Silicon Valley companies."
Nadella, 50, is in many ways the opposite of Ballmer. He is wiry, studious and measured. He is a passionate cricket enthusiast, thanks to a childhood spent playing around his home town of Hyderabad (one of Ballmer's first acts after leaving Microsoft was buying the Los Angeles Clippers basketball team).
Under his command, Microsoft has changed too. The company, once defined by its ruthlessly competitive nature, has become friendlier, more willing to team up with those who were once deemed enemies. Employees carry copies of The Growth Mindset, a book by the psychologist Carol Dweck about constant improvement. In Nadella's first move as Microsoft chief, he unveiled a version of its Office software developed for Apple's iPad. Windows 10, the first version of the software released under his watch, was given away for free, a move that once would have been unthinkable. And just a few months after inheriting the Nokia business, he began to dismantle it, accepting that there were some battles Microsoft could not win.
Instead of trying to compete on all fronts, Nadella has narrowed Microsoft's aims. The company's powerhouse divisions have turned out to be its productivity software such as Word, Excel and Outlook, and cloud computing, the division Nadella ran before becoming chief executive. Instead of demanding victory, Nadella now talks about helping others.
"What we have learned is to just be consistent in building trust and just making sure that you're not just measuring your success by your own success," he says.
That said, Nadella's four years in charge cannot be described as anything but a success. Under his watch, its share price has increased by 170 per cent, finally overtaking the levels from the peak of the dotcom boom.
It has been a long road from Microsoft's previous pomp. Twenty years ago this month, Microsoft - then the most powerful technology company in the world - was accused by the US government of exploiting its monopoly position in computer software to force people to use its own web browser. The company ultimately escaped without significant formal punishment, but was so chastened by the experience that it was put on the back foot when it came to the new wave of 21st century technology - personal media devices such as the iPod, and then the smartphone. It is only now that the company has regained its mojo.
Nadella may have reinvented Microsoft but he did not arrive as a fresh face in 2014. Having moved to the US from India to study (Nadella retains the accent, but with distinct US inflections) he arrived at Microsoft in 1992, when he was poached from Sun Microsystems. One senses there is still plenty of the old Microsoft fight there.
When I ask if he sees parallels between the antitrust case of two decades ago and today's fears over Silicon Valley's power, he bristles somewhat, and even goes so far as to defend the Microsoft of 1998 against the "closed" practices of many tech companies today.
"I always make this case, which is if it was not for Microsoft's openness, the web wouldn't have happened. I was talking to [web creator Sir] Tim Berners-Lee yesterday and I sort of said: 'Think about the current ecosystems and how closed and how walled gardened and riddled with all kinds of ways they've rigged it, [compared] to where we were.'
"Every company will need to go through and ask itself: 'Are you creating surplus around you or are you extracting surplus for yourself'. When that equation gets unbalanced I think things just have to correct."
When pressed on whether tech giants like Facebook and Google have too much power, Nadella insists it is not his job to remark on others.
Nadella recently described privacy as a "human right", a well-timed remark as sweeping new privacy rules come into force in Europe. He describes the new regulations as "robust" and creating "the right value around how users should think". The current debate around privacy also gives him a chance to burnish Microsoft's own privacy credentials. Unlike Google or Facebook, its services are paid for directly.
"Our business model is based on our customers being successful, and if they are successful they will pay us. So we are not one of these transaction-driven or ad-driven or marketplace-driven economies.
"I don't think I am necessarily saying one business model is better than the other but I do believe right now Microsoft is probably on the right side of history."
Nadella says many smaller businesses are confused over whether large technology companies are out to help or destroy them. Millions of companies and start-ups, for example, rely on Amazon's cloud computing arm, Web Services, but the wider company often represents an existential threat to many of them.
Although Nadella does not name Amazon, he indicates that the lack of such conflicts helps Microsoft.
"Customers are unclear [about] 'oh this is somebody I can go to for cloud computing but they are also competing with me, they also have this other system which is essentially a taxation system on all transactions.'
"Those are all, I think, things that customers think about. In our case they don't have to think about any of those because it's pretty unambiguous what our business is and what our business model is."
Despite this, Microsoft is not typically in the business of starting fights these days. Executives have appeared on stage at Apple events, and Amazon itself was invited to demonstrate a tie-up between its voice assistant Alexa and Microsoft's counterpart, Cortana, at a recent Microsoft conference. Nadella has bigger things on his mind after all. He is optimistic about the potential of technology - of imbuing everything from medicine to factories with internet connections and artificial intelligence (AI). While his childhood in India was relatively comfortable, it has given him a world-view distinct from many technology executives who grew up on a US coast.
His first child, Zain, a son, was born with severe disabilities and one of his daughters has learning disabilities that meant Nadella and his wife Anu spent many hours of her childhood driving from Seattle to a school in Vancouver.
Nadella is broadly optimistic that AI will solve more problems than it causes, but says it is imperative that the technology is applied ethically. "What I think needs to be done in 2018 is more dialogue around the ethics, the principles that we can use for the engineers and companies that are building AI, so that the choices we make don't cause us to create systems with bias ... that's the tangible thing we should be working on."
He is also confident that human jobs will survive the robot revolution. "I don't believe in that lump of labour fallacy, we don't know all the jobs that are going to be there." If robots do replace humans, he says mechanisms such as universal basic income may be needed, drawing comparisons with the labour movement, but that humans will always need jobs. "There is a certain amount of dignity to what is work so we need to have an incentive system."
In comparison, Brexit seems to concern him little. Microsoft warned before the referendum that a Leave vote could affect investment, but when the robot revolution comes, it will care little for such matters.
"The United Kingdom has great human capital, great industry, a great system," Nadella says. "I think in the future it'll continue to thrive, even if I think there are going to be some turns.
How it rose, fell, and rose again
Harvard drop-out Bill Gates and a childhood friend set up Microsoft, developing software to interpret the computer programming language BASIC.
Microsoft unveils the first version of Windows, featuring the graphical interface that set the foundations for today's computer software. Microsoft goes public a year later.
The US government accuses Microsoft of breaking antitrust law by using its dominance in computer operating systems to push out competitors to its web browser, Internet Explorer.
After 25 years, Bill Gates, now the world's richest man, hands the chief executive job to Steve Ballmer, Microsoft's 30th employee who has been at the company since 1980.
Microsoft cloud chief Satya Nadella, previously seen as an outside shot, takes control of the company six months after Ballmer announces his intentions to step down.