Microsoft has officially agreed to acquire Nokia Corporation's devices and services business today, sending shares of Nokia up nearly 37 percent in early trading. 

The deal comes with Nokia's license and patents, as well as the company's significant mapping business in tow. Under the terms of the agreement, Microsoft will pay $5.13 billion to purchase substantially all of Nokia's handset division, and $2.17 billion to license Nokia’s patents, for a total transaction price of $7.2 billion in cash. 

Microsoft said it will draw up its overseas cash resources to fund the transaction, which is expected to close in the first quarter of 2014 and is subject to approval by Nokia’s shareholders and regulators.

The news comes in the wake of Microsoft CEO Steve Ballmer's announcement last week that he will be retiring. Stephen Elop, Nokia's CEO and ex-Microsoft exec, has been rumored as a possible candidate to fill Ballmer's shoes. As of today's announcement, Elop will step aside as Nokia president and CEO to become executive vice president of devices & services for Nokia. 

Nokia's chairman of the board, Risto Siilasmaa, will assume the interim CEO position. 

During a press conference broadcast online, Siilasmaa called the decision to sell out to Microsoft an "emotional" and "complicated" one. He said that the bottom line was simply that Nokia did not have the capital necessary to compete in a market that has become a "duopoly." 

"Microsoft does have the resources, but they like a business model that allows them to gain an improved return on a significant incremental investment," Siilasmaa said.

Current Microsoft CEO Steve Ballmer said during the press conference that the acquisition will help Microsoft “accelerate phone share.” Ballmer said that the companies will continue to build and ship Lumia phones as they wait for regulatory approval. He also stressed that Finland will remain the hub for phone R&D, and Microsoft has no plans to shift where work on devices is currently being done. 

In a separate press release, Nokia said it plans retain its headquarters in Finland. Excluding the approximately 32,000 people planned to transfer to Microsoft, Nokia would have employed approximately 56,000 people at the end of the second quarter 2013. 

Nokia said it will continue to focus on its three established businesses: NSN, which provides network infrastructure and services; HERE, which provides mapping and location services; and Advanced Technologies, which provides technology development and licensing.

The joining of Nokia and Microsoft brings to a head not only the companies' announced February 2011 partnership to develop Lumia smartphones around Microsoft's Windows Phone operating system, but also the Finnish OEM's storied history. 

At its peak, Nokia traded for $40 per share in November of 2007 on the popularity of the company’s feature phones. Since then, Nokia has struggled to pivot  in an era defined by the Apple’s iPhone and other entrants like Samsung, which have developed high-end handsets around Google’s Android operating system. 

Shares of Nokia were up over 37 percentage in early trading to $5.36, while Microsoft was down 4 percent to $31.92. Credit Suisse, Bernstein, and Oppenheimer have all upgraded Nokia to neutral.