Microsoft announced late Monday night that it will buy Nokia's mobile phone business -- a momentous deal that pits Microsoft squarely against Apple and Google in the hotly contested smartphone arena.

The €5.4 billion ($7.2 billion) acquisition gives Microsoft control of the second-largest mobile phone manufacturer in the world, according to IDC. The Finnish Nokia (NOK) is well behind Samsung in cell phone sales but far ahead of third-place Apple (AAPL), according to IDC.

Yet Nokia is a deeply troubled company and is rapidly losing relevance.

That's particularly true in the smartphone market that Microsoft (MSFT) covets. Nokia, once dominant in the sector, no longer cracks the top five manufacturers in the world.

Sales of Nokia's top-of-the-line Lumia smartphones are growing fast, but they're coming off such a low baseline that the phones still remain largely irrelevant compared to iPhone, Samsung Galaxy S4 and even Google's new Moto X, which have all captured more buzz.

Apple and Google (GOOG) control 86% of the smartphone market, while Microsoft's Windows Phone operating system has just a 3.7% share.

In its strategic rationale for the deal, Microsoft said it cannot cede complete control of the smartphone phone market to Google and Apple, allowing its rivals to "foreclose app innovation, integration, distribution or economics."

"We are very excited to bring the best mobile device efforts of Microsoft and Nokia together," Steve Ballmer, Microsoft's outgoing CEO, said at a press conference in Finland. Ballmer characterized the deal as a "win-win" for both companies. Nokia shares spiked more than 45% in Helsinki trading.

Related story: Microsoft CEO Steve Ballmer to retire

Nokia is something of a natural fit for Microsoft. The companies reached a strategic partnership in 2011 in which Nokia transitioned away from its homemade Symbian smartphone platform, replacing it with Microsoft's Windows Phone. Nokia made 82% of the Windows Phone devices sold last quarter -- a figure that continues to grow as Samsung, HTC and other Microsoft partners are barely dipping their toes in the Windows Phone waters.

Nokia has been led for the past three years by Stephen Elop, a former Microsoft executive. Elop stepped down as Nokia's CEO on Monday to become the head of the company's devices and services business. He will continue on leading Nokia's phones business as the devices chief at Microsoft.

Elop has been widely named as a potential replacement for Ballmer as Microsoft's next CEO. He replaces Julie Larson-Green, also believed to be a CEO candidate, as head of Microsoft's devices business. Larson-Green will now report to Elop.

The devices business is crucial for Microsoft as it attempts to battle Apple, Samsung and a host of other popular gadget makers as consumers shift away from Windows PCs to iPads, Android tablets and smartphones. Microsoft is amid a large-scale transition to become a "devices and services company" and not just a software maker.

In addition to Nokia's mobile phone business, the deal also gives Microsoft access to a treasure trove of patents as well as Nokia's widely used mapping services.

Nokia's origins date back 150 years to a wood pulp mill in southwestern Finland. The company got into the telephone business in 1963 and became the world's largest mobile phone maker in 1998 -- a title it ceded to Samsung last year.