Sarah Tew/CNET

Microsoft will acquire Nokia's devices and services unit and license the company's mapping services in a deal worth $7.2 billion in a bid to bolster the company's position in the smartphone market.

The software giant will pay $5 billion for "substantially all" of Nokia's phone unit and another $2.2 billion to license its patents, the companies announced late Sunday. As part of the deal, Stephen Elop will step down as Nokia chief executive to become the executive vice president of the devices and services division. Elop, a former Microsoft executive, is one of a handful of candidates suggested to replace Microsoft Steve Ballmer, who is expected to retire by next summer.

"Today's agreement will accelerate the momentum of Nokia's devices and services, bringing the world's most innovative smartphones to more people, while continuing to connect the next billion people with Nokia's mobile phone portfolio," Ballmer and Elop said in a joint statement.

Elop, the former president of the Microsoft Business Division, left the software giant three years ago this month to head up Nokia. He joined Microsoft in January 2008 after serving as COO of Juniper Networks and as an executive at Adobe Systems.

"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," Elop said in a statement. "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 Chairman Risto Siilasmaa will become Nokia's interim CEO while the company searches for a permanent replacement.

"For Nokia, this is an important moment of reinvention and from a position of financial strength, we can build our next chapter," Siilasmaa said. "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."

Also joining Microsoft as part of the deal are Jo Harlow, Juha Putkiranta, Timo Toikkanen, and Chris Weber.

The acquisition suggests that like Apple, Microsoft believes it needs more direct control of handset manufacturing to succeed in the smartphone market. The relationship between Microsoft and Nokia began in February 2011 when Elop, who had arrived at the beleaguered Finnish handset maker from Microsoft five months earlier, announced at a developer's conference that Nokia was adopting Windows Phone 7 as its primary smartphone OS.

At the time, Nokia was lagging far behind in the smartphone wars and was looking to grown beyond its own MeeGo and Symbian platforms. Google's Android OS was another contender, but Elop promised that a Microsoft partnership would encompass phones, developers, mobile services, partnerships with carriers, and app stores to distribute software.

Two days later at the 2011 Mobile World congress in Barcelona, Spain, Elop expanded on the news with a promise that Nokia would "swing" the market toward Microsoft's Windows Phone 7 platform. The company's first phones began to arrive later that year with its first flagship device, the Nokia Lumia 900, arriving almost a year later at the 2012 CES.

Despite market domination by Android and Apple's iOS, handsets running Microsoft's Windows Phone operating system seem to be gaining in popularity, especially among new users. Kantar Worldpanel ComTech reported this weekend that at the end of July Windows Phone dominated 8.2 percent of the five major European markets, including the UK, France, and Germany.

As part of the deal, Nokia will grant Microsoft a 10-year non-exclusive licence to its patents, and Microsoft will grant Nokia reciprocal rights to use to its location-based patents.

The deal, which is expected to close in the first quarter of 2014, is still subject to shareholder and regulatory approval. When the deal closes, approximately 32,000 Nokia employees will transfer to Microsoft, including 4,700 in Finland and 18,300 involved in manufacturing.

CNET's Kent German contributed to this report.