Microsoft CEO Steve Ballmer and Nokia CEO Stephen Elop. AP Microsoft announced tonight that it will buy Nokia's devices and services division.

This is the part of Nokia that makes smartphones (and soon) tablets.

Microsoft will pay 3.70 billion Euro for Nokia's devices business. That's nearly $5 billion is U.S. dollars. Microsoft will also pay an additional 1.65 billion Euro ($2.2 billion U.S.) for the rights to Nokia's patents.

All together, the deal will cost Microsoft about $7 billion U.S.

Microsoft will also take on about 32,000 Nokia employees. Nokia's CEO Stephen Elop will transfer to Microsoft too. (Elop used to work at Microsoft before becoming the Nokia CEO.)

The joining of Microsoft and Nokia isn't a huge surprise. Nokia is the only manufacturer that exclusively uses Microsoft' Windows Phone 8 operating system for its top-tier smartphones. Meanwhile, Microsoft has struggled to gain significant market share for Windows Phone as Android and the iPhone continue to dominate.

Nokia's flagship Lumia phones are most likely the best-selling Windows Phones today. The company sold 7.4 million last quarter. A lot of those sales are due to the fact that Nokia attacks the low-end of the smartphone market with cheaper devices. It also makes high-end phones like the Lumia 920, 925, and 1020.

This can also be another sign that Microsoft is taking its transition from a software company to a "devices and services" company much more seriously. Until last year, Microsoft did not make any major products (besides the Xbox) itself. That changed with its line of Surface tablets that run the new Windows 8 operating system. The company announced that it was making the transition to a company that provides both devices and services.

But Microsoft has yet to make a smartphone of its own, despite numerous rumors that it had plans to. By buying Nokia, Microsoft now has its own manufacturer that it can work closely with.

Microsoft's purchase isn't likely to annoy other manufacturers that make Windows Phones either. Most of those manufacturers (Samsung, HTC, etc.) have been able to make more money from Android devices than an alternative operating system like Windows Phone 8. Nokia is the only manufacturer that relies almost entirely on Windows Phone 8.

Finally, there's Elop. He's one of the names that have been floating around as a potential replacement for Steve Ballmer as Microsoft's CEO. Ballmer announced last month that he plans to retire within a year. A special team of Microsoft board members is now on the hunt for a new CEO.

Here's the press release:

Microsoft Corporation and Nokia Corporation today announced that the Boards of Directors for both companies have decided to enter into a transaction whereby Microsoft will purchase substantially all of Nokia’s Devices & Services business, license Nokia’s patents, and license and use Nokia’s mapping services.

Under the terms of the agreement, Microsoft will pay EUR 3.79 billion to purchase substantially all of Nokia’s Devices & Services business, and EUR 1.65 billion to license Nokia’s patents, for a total transaction price of EUR 5.44 billion in cash. Microsoft will draw upon its overseas cash resources to fund the transaction. The transaction is expected to close in the first quarter of 2014, subject to approval by Nokia’s shareholders, regulatory approvals and other closing conditions.

Building on the partnership with Nokia announced in February 2011 and the increasing success of Nokia’s Lumia smartphones, Microsoft aims to accelerate the growth of its share and profit in mobile devices through faster innovation, increased synergies, and unified branding and marketing. For Nokia, this transaction is expected to be significantly accretive to earnings, strengthen its financial position, and provide a solid basis for future investment in its continuing businesses.

“It’s a bold step into the future – a win-win for employees, shareholders and consumers of both companies. Bringing these great teams together will accelerate Microsoft’s share and profits in phones, and strengthen the overall opportunities for both Microsoft and our partners across our entire family of devices and services,” said Steve Ballmer, Microsoft chief executive officer. “In addition to their innovation and strength in phones at all price points, Nokia brings proven capability and talent in critical areas such as hardware design and engineering, supply chain and manufacturing management, and hardware sales, marketing and distribution.”

“We are excited and honored to be bringing Nokia’s incredible people, technologies and assets into our Microsoft family. Given our long partnership with Nokia and the many key Nokia leaders that are joining Microsoft, we anticipate a smooth transition and great execution,” Ballmer said. “With ongoing share growth and the synergies across marketing, branding and advertising, we expect this acquisition to be accretive to our adjusted earnings per share starting in FY15, and we see significant long-term revenue and profit opportunities for our shareholders.”

“For Nokia, this is an important moment of reinvention and from a position of financial strength, we can build our next chapter,” said Risto Siilasmaa, Chairman of the Nokia Board of Directors and, following today’s announcement, Nokia Interim CEO. “After a thorough assessment of how to maximize shareholder value, including consideration of a variety of alternatives, we believe this transaction is the best path forward for Nokia and its shareholders. Additionally, the deal offers future opportunities for many Nokia employees as part of a company with the strategy, financial resources and determination to succeed in the mobile space.”

“Building on our successful partnership, we can now bring together the best of Microsoft’s software engineering with the best of Nokia’s product engineering, award-winning design, and global sales, marketing and manufacturing,” said Stephen Elop, who following today’s announcement is stepping aside as Nokia President and CEO to become Nokia Executive Vice President of Devices & Services. “With this combination of talented people, we have the opportunity to accelerate the current momentum and cutting-edge innovation of both our smart devices and mobile phone products.”

Nokia has outlined its expected focus upon the closing of the transaction in a separate press release published today.

TERMS OF THE AGREEMENT

Under the terms of the agreement, Microsoft will acquire substantially all of Nokia’s Devices and Services business, including the Mobile Phones and Smart Devices business units as well as an industry-leading design team, operations including all Nokia Devices & Services-related production facilities, Devices & Services-related sales and marketing activities, and related support functions. At closing, approximately 32,000 people are expected to transfer to Microsoft, including 4,700 people in Finland and 18,300 employees directly involved in manufacturing, assembly and packaging of products worldwide. The operations that are planned to be transferred to Microsoft generated an estimated EUR 14.9 billion, or almost 50 percent of Nokia’s net sales for the full year 2012.

Microsoft is acquiring Nokia’s Smart Devices business unit, including the Lumia brand and products. Lumia handsets have won numerous awards and have grown in sales in each of the last three quarters, with sales reaching 7.4 million units in the second quarter of 2013.

As part of the transaction, Nokia is assigning to Microsoft its long-term patent licensing agreement with Qualcomm, as well as other licensing agreements.

Microsoft is also acquiring Nokia’s Mobile Phones business unit, which serves hundreds of millions of customers worldwide, and had sales of 53.7 million units in the second quarter of 2013. Microsoft will acquire the Asha brand and will license the Nokia brand for use with current Nokia mobile phone products. Nokia will continue to own and manage the Nokia brand. This element provides Microsoft with the opportunity to extend its service offerings to a far wider group around the world while allowing Nokia’s mobile phones to serve as an on-ramp to Windows Phone.

Nokia will retain its patent portfolio and will grant Microsoft a 10-year license to its patents at the time of the closing. Microsoft will grant Nokia reciprocal rights to use Microsoft patents in its HERE services. In addition, Nokia will grant Microsoft an option to extend this mutual patent agreement in perpetuity.

In addition, Microsoft will become a strategic licensee of the HERE platform, and will separately pay Nokia for a four-year license.

Microsoft will also immediately make available to Nokia EUR 1.5 billion of financing in the form of three EUR 500 million tranches of convertible notes that Microsoft would fund from overseas resources. If Nokia decides to draw down on this financing option, Nokia would pay back these notes to Microsoft from the proceeds of the deal upon closing. The financing is not conditional on the transaction closing.

Microsoft also announced that it has selected Finland as the home for a new data center that will serve Microsoft consumers in Europe. The company said it would invest more than a quarter-billion dollars in capital and operation of the new data center over the next few years, with the potential for further expansion over time.

NOKIA LEADERSHIP CHANGES

Nokia expects that Stephen Elop, Jo Harlow, Juha Putkiranta, Timo Toikkanen, and Chris Weber would transfer to Microsoft at the anticipated closing of the transaction. Nokia has outlined these changes in more detail in a separate release issued today.

EXTRAORDINARY SHAREHOLDERS MEETING

Nokia plans to hold an Extraordinary General Meeting on November 19, 2013. The notice of the meeting and more information on the transaction and its background are planned to be published later this month.