Microsoft has agreed a deal to buy Nokia's mobile phone business for 5.4bn euros ($7.2bn; £4.6bn).

Nokia will also license its patents and mapping services to Microsoft. Nokia shares jumped 35% on the news, whereas Microsoft's fell more than 5%.

The purchase is set to be completed in early 2014, when about 32,000 Nokia employees will transfer to Microsoft.

Nokia has fallen behind rivals Samsung and Apple, while critics say Microsoft has been slow into the mobile market.

Describing the deal as a "big, bold step forward", Microsoft chief executive Steve Ballmer told the BBC that his company was in the process of transforming itself from one that "was known for software and PCs, to a company that focuses on devices and services".

Analysis

So who wins and who loses from this deal? Nokia shareholders may be breathing a sigh of relief. Yes, they are only getting $7bn for a business that had a market capitalisation of $150bn in 2007.

But the 40% rise in the share price this morning shows they feel this is a far better outcome than they might have expected after years of decline.

As for Microsoft, it will be a while before we know whether Steve Ballmer's last big gamble as CEO has paid off.

He sees this deal as the final piece in the jigsaw, in his strategy to turn the software company into a devices and services business.

At the Helsinki press conference he talked of beating Blackberry for third place in the mobile phone market - and Microsoft's investors may find that number three is not a very profitable place to be.

For Finland and for Europe as a whole, this must be seen as a sad day. It is hard to remember just how recently Nokia was Europe's technology superstar, with a 40% share of one of the world's fastest growing industries and a proud record of innovation.

"We've done a lot of great work in the two-and-a-half years that we've been in partnership with Nokia, going literally from no phones to 7.4 million smart Windows phones in the last quarter that was reported," he said.

But he admitted: "We have more work to do to expand the range of applications on our product."

Priority move

Microsoft, one of the biggest names in the technology sector, has struggled as consumers have shunned traditional PCs and laptops in favour of smartphones and tablet PCs.

Critics say the firm has been too slow to respond to the booming market for mobile devices. It launched its Surface tablet PCs last year, but sales of the devices have been relatively slow.

Analysts said that the company wanted to make sure that it got its strategy right in the mobile phone market.

"Mobile is an area of tremendous potential but it has been one of weakness for Microsoft," Manoj Menon, managing director of consulting firm Frost & Sullivan, told the BBC.

"Clearly the number one priority for the company is to get its mobile strategy right. From a strategy point of view, this deal is the perfect step, The only question is how well they can execute this plan."

Ben Wood, an analyst at telecoms consultancy CCS Insight, said: "It's a necessary gamble by Microsoft to break into mobile, but given its complete reliance on Nokia for Windows Phone devices and the competitive position of Apple and Google with rival phone platforms an understandable move.

"It completely reshapes Microsoft's business pushing it firmly into hardware. But it also raises big questions about the sustainability of other firms, including HTC and Blackberry, remaining pure-play phone makers," he added.

'Tighter integration'

Nokia was once a leader in mobile phones, but the firm's sales fell 24% in the three months to the end of June from a year earlier.

Nokia through the years

1871: Founded. Spends the next century making tyres, boots and cables.

It sold 53.7 million mobile phones during the quarter, down 27% on last year.

However, sales of its new Lumia phones, which run a Microsoft operating system, rose during the period.

Mr Menon said that the deal between the two companies would help to bring the "hardware closer to the operating system and achieve a tighter integration".

"This should help Microsoft make a more effective strategy to compete in the mobile sphere," he said.

Microsoft has also agreed a 10-year licensing arrangement with Nokia to use the Nokia brand on current mobile phone products.

Management changes

Nokia also announced changes to its leadership team as a result of the sale. Stephen Elop will step down as president and chief executive of Nokia Corporation and resign from the company's board.

The firm said that he would become the executive vice president of the Devices & Services unit, adding that it expected him to "transfer to Microsoft at the anticipated closing" of the deal.

The transfer of Mr Elop to Microsoft comes at a time when the company is looking for a new chief executive.

The current head of Microsoft, Steve Ballmer, announced last week that he would be retiring and is expected to leave the company within the next 12 months.

Summing up his tenure at the helm of one of the world's largest technology companies, he told the BBC: "I'm pleased with what we've achieved; I'm pleased with the level of innovation we've brought to intelligent devices around the globe.

"But there's always another challenge and with this acquisition we'll take things up to the next level."

Mr Elop who left Microsoft to join Nokia in 2010, has been cited by some as one of the frontrunners to replace Mr Ballmer.

Nokia's future

The transaction is still subject to approval by Nokia shareholders and regulators.

Nokia says that once the sale is completed, it will concentrate on three key businesses - network equipment manufacturing, mapping and location services, and the development and licensing of technology.