The meeting took place a week before Bill Gates retired from Microsoft, and the topic was open source software.

It was the summer of 2008, and for years, the open source community had viewed Microsoft as public enemy number one. Seven years earlier, CEO Steve Ballmer had referred to Linux as a "malignant cancer," and as recently as the previous summer, Microsoft general counsel Brad Smith and licensing chief Horacio Gutierrez had told Fortune Magazine that Linux violated 235 of its patents, implying that it would soon demand royalties from any big business using the open source OS.

But at the same time, Microsoft realized how powerful the free software movement could be, and the company was exploring ways it could make nice with the ever-growing community of developers who used open source. For two years, Sam Ramji had served as head of open source strategy at Microsoft, and every three months, he met with Bill Gates and other execs to show off various open source technologies put together by a small team of Microsoft engineers.

But that afternoon was different. At the invitation of the company's chief legal minds – Smith and Gutierrez – Ramji sat down with Gates, chief software architect Ray Ozzie, and a few others to discuss whether Microsoft could actually start using open source software. Ramji and Ozzie were on one side of the argument, insisting that Microsoft embrace open source, and Gutierrez offered a legal framework that could make that possible. But other top executives strongly challenged the idea.

Then Bill Gates stood up.

He walked to the whiteboard and drew a diagram of how the system could work, from copyrights to code contribution to patents, and he said – in no uncertain terms – that the company had to make the move.

For Ramji – who would spend more than three and a half years as the company's chief open source strategist – the moment Bill Gates stood up was the moment Microsoft turned the corner on its approach to free software. "He was given little to no credit by the open source community – or anyone in the tech industry – for really understanding open source and why it can be important, how it can be a competitive advantage, and why when your competitors start to use it, you have to too. He really got it, and in that moment, he taught us all."

From the outside looking in, it appears that Microsoft has indeed turned the corner. The company recently added two open source platforms to Windows Azure – its new-age web service for building and hosting applications on the net – and it's actually contributing open source code to these projects – as well as others. These aren't minor open source projects. They're big name projects with huge followings: Node.js and Hadoop. This would not have happened in the past.

Microsoft changed because of people like Sam Ramji and the man who hired him, Bill Hilf – not to mention Bill Gates. But the change also reflects a much larger movement across the tech industry. As more and more applications move from local data centers to "cloud" services such as Amazon Web Services and, yes, Microsoft Azure, the economics of software are shifting. In the past, businesses paid companies like Microsoft for software and loaded it on their own servers. Now, businesses pay to use online services instead. In offering open source software atop Azure, there's a clear way for Microsoft to actually make money.

"With Azure, we make money from compute and storage and bandwidth," says Hilf, who now oversees Azure. "We want to offer as many types of applications and as many types of systems as we can, so they can help that flywheel spin.... We don’t see [Node.js] on Azure as altruistic. We see it as a way to drive business."

Bill Hilf, Microsoft first head of open source. Photo: Microsoft

'The First Astronaut on the Planet'

Bill Hilf was a Linux guy. As a senior architect at IBM in the early 2000s, he built big business infrastructure using Linux and other open source software, and he was eventually tapped to oversee open source strategy for all of Big Blue. IBM had bet big on Linux in the late '90s as a way of battling the Microsofts of the world. Then, in 2004, Hilf got a call from his biggest rival.

"Microsoft called up and said: 'We don't understand this open source stuff. And we need people who do,'" Hilf remembers. "I was like the first astronaut on the planet."

His main task, at least initially, was to teach. "I spent a lot of time just educating people on what the open source process was: How does open source work? How community software on the internet work? How do licenses work? Do these people really work for free?" But he also helped build an open source lab inside Microsoft where he and his cohorts would build Linux systems and test them in tandem machines running Windows software. For a company that had longed shunned the Samba project – an open source effort to ensure that Windows desktops could talk to Linux file servers and not just Windows servers – this was a significant undertaking.

>"Microsoft called up and said: 'We don't understand this open source stuff. And we need people who do.' I was like the first astronaut on the planet."

At the same time, Hilf's lab would explore new Microsoft projects that might grow out of existing open source efforts. And toward the end of his time on the job, he began to reach out to members of the open source community. "We wanted to understand the ways we could work cooperatively with open source – not just learning how it works and testing to see if we could inter-operate, but looking for areas where we could really pursue open source," he says.

This sort of thinking, Hilf says, led to Microsoft's involvement with Node.js and Hadoop. Last year, the company not only announced that it would port Node and Hadoop – both Linux technologies – to Windows. It said it would contribute the code back to the open source community.

"We have a dedicated team of people who are working on this. We're doing real engineering work," Hilf says. "Then we're taking that work and putting it under an open source license and distributing it through something like Github. That would not have happened six years ago."

This fall, Microsoft even contributed code to Samba. "A few years back, a patch submission from coders at Microsoft would have been amazing to the point of unthinkable, but the battles are mostly over and times have changed," wrote Christopher Hertel and his fellow Samba contributors.

"Most people didn’t even notice the source of the contribution. That’s how far things have come in the past four-ish years… but some of us saw this as a milestone, and wanted to make a point of expressing our appreciation for the patch and the changes we have seen."

A Company That's At Its Best When Freaking Out

But the road was a long one. In 2006, when Hilf hired Sam Ramji to take over Microsoft's open source efforts, the company's relationship to free software was still uneasy. A year later, Brad Smith and Horacio Gutierrez would make those apparent threats to the Linux community in the pages of Fortune. And when Ramji was hired to run open source at Microsoft, as he acknowledged years later, he was a little skeptical of the role – and a little scared.

There were ups, and there were downs. But Ramji's meeting with Gates meant that the big changes would eventually happen. Not long after the meeting, Microsoft purchased a company called Powerset, a semantic search startup that was among the first companies to run a web service atop Hadoop. After a short hiatus, Microsoft allowed Powerset's engineers to continue contributing code to the open source project. And for a while, the service continued to run on Hadoop, a means of crunching data across a sea of servers. At some point, the project abandoned the technology and moved the service to Microsoft software, and at least one of the main open source contributors left the company. But Powerset was at least a step in the right direction.

The following year, Ramji and his team prototyped an Amazon-like cloud service using nothing but open source software such as Zend and OpenNebula and Eucalyptus and OpenScale and Hadoop. "We were like the beta squadron," Ramji remembers. "We were the attack squadron that would come test everybody. We would say: 'You think you're ahead? Let us show you what can be done with open source and two weeks of time and some smart Linux guys."

According to Ramji, the project caused "deep discomfort" among the Microsoft braintrust. The company was already building Azure – then code-named Red Dog – using proprietary technologies. But for Ramji, deep discomfort is a good thing. "Microsoft is at its best when it's freaking out," he says. "That's just it's mentality. It's a crisis-oriented company."

Microsoft Becomes Google

Ramji left Microsoft in 2009 and joined a startup called Apigee, tackling what he sees as today's equivalent of the early open source movement: the effort to integrate the world's web services through application programming interfaces, or APIs. But he left a mark in Redmond. Projects like that open source cloud stack had the desired effect.

"I think that the team that we built is the best team I've ever worked with," Ramji says. "We really carried the belief that we have to let the outside in. We can't continue, in this world, to only use proprietary approaches that are only going to let in the jingos – the flag-waving Microsoft fans." The team spread across the company, taking this ideas with them.

Azure still runs on proprietary Microsoft software. But to the surprise of many, the service is offering developers a wide range of open source tools they can use to build their applications, including not only Node and Hadoop but open source languages such as Java and PHP. The company has even said it will eventually allow developers to run Linux atop the service.

Ramji acknowledges that Microsoft changed in part because the world changed. "There is no greater power in the world than an idea whose time has come," Ramji says, paraphrasing Victor Hugo. But then he puts it in more prosaic terms: "Cloud is peanut butter for open source's chocolate."

>"Personally, I think that the chapter on Microsoft on open source has yet to be written. We need to see a lot more contribution from them to say they are a friend of open source."

But Microsoft's history as the enemy of open source is a long one, and many still question whether the company has indeed changed its ways. "Personally, I think that the chapter on Microsoft on open source has yet to be written," says Ron Schnell, a longtime open source user who also happened to run the Technical Committee that oversaw Microsoft’s consent decree with the U.S. government after the company lost its big antitrust case in 2001. "We need to see a lot more contribution from them to say they are a friend of open source."

In the end, Schnell says, it all comes down to money. "Open source solutions don't generally look good on the balance sheet. The question is – with the anticipated success of cloud computing, which would reduce the need for desktop operating systems like Windows, can Microsoft continue to see the sort of profits they've been seeing anyway?" That is the question. But the move to cloud computing certainly makes it easier to build an attractive balance sheet with open source software. And clearly, Microsoft realizes this.

For years, it's been easy to praise Google for being a friend to open source, while vilifying Microsoft for keeping its distance from free software. But as a web service, Google was in a very different position from Microsoft, a company that reached its heights selling shrink-wrapped boxes of code. Now, Microsoft is also a web company. It's becoming more like Google – in more ways than one.

Yes, Microsoft is demanding – and in many cases, receiving – royalties from companies selling devices that run Android, an operating system based on Linux. This shows that its place in the world remains complicated. Though it's moving to the web, it is still very much a company that makes money selling software – and it still has an interest in protecting this business. But these battles aren't always what they seem. Android isn't as much an open source project as a Google project.

The world is not black and white. And neither is the world of software. Not everyone realizes this. But Bill Gates did. And Microsoft is the better for it.