The software giant will pay $196 a share – a premium of almost 50% to Friday’s closing share price.
The deal will help Microsoft boost sales of its business and email software.
Microsoft said that LinkedIn would retain its “distinct brand, culture and independence”.
Ben Wood, head of research at CCS Insight, said the deal would give Microsoft access to the world’s biggest professional social network with more than 430 million members worldwide.
Watch: LinkedIn co-founder Reid Hoffman’s business secrets
“That’s a valuable asset that can be deeply integrated with a number of Microsoft assets such as Office 365, Exchange and Outlook. That said, Microsoft has stated that the company will continue to operate as an independent business, so we’ll have to see how deeply the integration occurs,” Mr Wood said.
Analysis: Rory Cellan-Jones, technology correspondent
Ever had one of those annoying LinkedIn emails inviting you to “endorse” a contact for some skill or another? Perhaps LinkedIn chief executive Jeff Weiner and its founder Reid Hoffman deserve to be endorsed for salesmanship after today’s deal.
After a tricky period in which the shares have fallen amid widening losses, they have persuaded Microsoft to make its biggest deal. The software giant is paying a 50% premium on Friday’s closing share price to buy LinkedIn, a price which amounts to $250 (£170) for every active user. To put that into context, that’s about the market value of Sky, or eight times as much as Daily Mail owner DMGT – and they are both profitable.
But this deal is about more than money: it is meant as a powerful signal of where Satya Nadella is now taking Microsoft. He sees its future as a cloud computing business providing all sorts of professional services to clients – including a social network to connect them to each other.
“We are trying to ride the wave of the new technologies,” Mr Nadella told me from Seattle. “It’s about AI, it’s about mobile, it’s about cloud and we’re trying to bring those things together.”
However, the deal to buy Nokia’s mobile phones division had a similar logic – and the entire value of that purchase was written off just a year later. So Microsoft’s investors may look at that $26bn price tag nervously, while anyone with a few LinkedIn shares may be using the network to send a message of congratulations to their board.
Microsoft chief executive Satya Nadella said he had long admired LinkedIn: “I have been thinking about this for a long time.”
The deal was “key to our bold ambition to reinvent productivity and business processes”, he added.
LinkedIn shares soared 47%, or $61.50, to $192.60 in New York following the announcement of the deal.
Shares in the company, which floated in May 2011, have fallen by more than 40% this year.
The stock plunged by a quarter in February after the company issued a profit warning for the first quarter and reported an annual loss of $166m.
Ivan Feinseth, analyst at Tigress Financial Partners, said that LinkedIn was a great business “even though the company stubbed their toe back in February. It’s a premium company and it deserves a premium valuation.”
Shares in Microsoft fell 2.6% to $50.16, bringing the decline this year to almost 10%.
‘Incredible opportunity’
Jeff Weiner will remain chief executive, reporting to Mr Nadella. He and Reid Hoffman – the chairman, co-founder and controlling shareholder of LinkedIn – both backed the deal.
“Today is a re-founding moment for LinkedIn,” said Mr Hoffman. “I see incredible opportunity for our members and customers and look forward to supporting this new and combined business.”
LinkedIn has been trying to expand by offering users more messaging options, mobile apps and a revamped “newsfeed” to help boost engagement.
Last year, the site pledged to send less frequent and “more relevant” messages after numerous user complaints.
The takeover is by far the biggest acquisition made by Microsoft, which paid $8.5bn for Skype in 2011 and bought Nokia’s mobile phone business for $7.2bn in 2013.
The LinkedIn acquisition also eclipses the $19bn that Facebook paid for WhatsApp in 2014.
Despite having a cash pile of about $92bn, Microsoft said it would pay for LinkedIn mostly by issuing new debt.
It expects the deal, which must be approved by regulators in the US, EU, Canada and Brazil, to generate annual savings of $150m by 2018.