Microsoft, fully embracing a model it once saw as a threat, said on Monday that it was buying GitHub, an open software platform used by 28 million programmers, for $7.5 billion.

The deal is a bid by Microsoft to gain ground in the internet era of software development, where applications increasingly run on remote data centers — on so-called cloud computing.

Amazon is the leader in the cloud market so far, but Microsoft has transformed itself in recent years to become a strong No. 2 as a supplier of cloud computing services. Its vital Office productivity applications and database software are available in cloud versions.

Microsoft also competes with Google, IBM, Salesforce and others in the cloud marketplace. All of them are trying to lure software engineers to use their cloud tools and services. The more programmers on a company’s platform, the more software applications are created, attracting customers and still more developers — a flywheel of growth and profit.

“The strategic battle in the tech world is for developers,” said Frank Gens, chief analyst for IDC, a research firm. “For Microsoft, the GitHub deal is about strengthening and widening its relationships with developers.”

Satya Nadella, Microsoft’s chief executive, said the deal would advance Microsoft’s ambitions in cloud computing and bring smarter software to every industry, on any digital device.

GitHub, founded in 2008 and based in San Francisco, was created largely as a community for software developers to share programming tools and code. It has been a champion of the open-source software movement, with its ethos of freely sharing code in public.

Today, GitHub is used by a wide range in the tech community, from lone programmers to the nation’s largest companies. Developers can share code, make comments and buy software tools. They work in digital storage spaces, called repositories. Some are open to all users; others are closed to members of a team. GitHub now has more than 85 million code repositories.

Individuals can use GitHub for free. But there are monthly subscription charges for extra storage, development tools and private repositories. The company does not disclose its revenue, but analysts estimate it is running at $200 million a year.

The open-source model was once anathema to Microsoft, the largest commercial software company, which had favored keeping its code proprietary. Steven A. Ballmer, Microsoft’s former chief executive, once called Linux, the popular open-source operating system, a “cancer” in the body of the technology business.

But Microsoft has come to embrace open-source tools. Today, Microsoft is the most active corporation on GitHub, with more than two million contributions of code to GitHub projects.

GitHub, seeking to establish a profitable business, has increasingly hosted corporate projects on its platform for a fee. Those ventures have typically used open-source software development techniques while keeping some code proprietary.

Executives from both companies insisted that GitHub would remain technologically neutral, welcoming developers using any code or any cloud service, rather than a Microsoft walled garden. The proof, analysts say, will be in how GitHub operates under Microsoft ownership.

“Developers by their nature are often suspicious of corporate ambitions,” said Ed Anderson, an analyst at Gartner. “Microsoft will have to demonstrate its willingness to put the interests of developers ahead of any Microsoft-specific agenda.”

The $7.5 billion purchase, an all-stock deal, is the second-largest acquisition Microsoft has made since Mr. Nadella became chief executive in early 2014. The bigger deal came in 2016, when Microsoft bought LinkedIn, the social network for professional workers, for $26.2 billion. (GitHub ranks third in Microsoft’s history, also behind the $8.5 billion purchase of Skype in 2011.)

If GitHub will remain a neutral home for developers, as Microsoft insists, why did the company pay so handsomely to own it?

In an interview, Nat Friedman, corporate vice president for developer services at Microsoft, explained that ownership would give the company the confidence to make a greater commitment to GitHub — “to confidently go all-in on GitHub.”

Microsoft, Mr. Friedman said, will make nearly all its software-building tools available on GitHub. Over time, as Microsoft shows itself to be a reliable corporate steward of GitHub and is willing to invest in its growth, he said, Microsoft should benefit as more developers adopt its software.

“It’s a matter of building trust with developers,” said Mr. Friedman, who will become chief executive of GitHub when the deal closes, which is expected to be this year. “You earn the right to be considered for other things.”

With GitHub, Microsoft is making a move similar to its LinkedIn acquisition — buying the leading marketplace in its field. “Microsoft is rolling up another platform,” said Michael A. Cusumano, a professor at Massachusetts Institute of Technology’s Sloan School of Management.

GitHub has become far more than a platform for software development. It is where developers demonstrate their skills. Software engineers routinely include links to their GitHub projects on their résumés, and companies scout for job candidates on GitHub.

“It’s the de facto tool for recruiting technical talent,” Julio Avalos, GitHub’s chief strategy officer, said in an interview this year.

The $7.5 billion transaction promises a lucrative payday for GitHub’s venture backers. The start-up had raised a total of $350 million — a $100 million round in 2012, led by Andreessen Horowitz, and a $250 million round in 2015, led by Sequoia Capital.

The multibillion-dollar deal is a long way from GitHub’s hobbyist, hacker origins. In a blog post, Chris Wanstrath, the company’s chief executive and a co-founder, who will become a technical fellow at Microsoft, wrote that when GitHub started up a decade ago, he could have “never imagined” the outcome announced on Monday.

“Git was a powerful but niche tool, clouds were just things in the sky,” he wrote, “and Microsoft was a very different company.”

A version of this article appears in print on , on Page B1 of the New York edition with the headline: Deal Lifts Microsoft As It Woos Developers. Order Reprints | Today’s Paper | Subscribe