Nokia will grant the US software giant a 10-year non-exclusive licence to its patents and will itself focus on network infrastructure and services, which it called "the best path forward for Nokia and its shareholders."
Nokia dominated the mobile phone market for 14 years, until it was overtaken by Samsung in 2012 as the top-selling brand, as it struggled to establish winning business models and mobile devices.
Rumours of a Nokia sale have swirled in recent months.
Amid increasing competition from Apple and Samsung, Nokia dramatically changed its strategy in February 2011 when Elop warned the company was "standing on a burning platform" and needed to shift course immediately.
Nokia bet its future on its new Lumia smartphones, aiming to rival Apple's iPhone and Samsung's Galaxy.
But Tuesday's announcement marks the end of Nokia's days as an independent phone manufacturer.
Some 32,000 Nokia employees are expected to transfer to Microsoft once the deal is concluded, including approximately 4,700 people in Finland, the company said.
The operations affected by the transfer generated approximately 14.9 billion euros in 2012, or almost 50% of Nokia's net sales, it added.
Of the total purchase price of 5.44 billion euros, 3.79 billion relates to the purchase of Nokia's devices and services business, and 1.65 billion relates to the mutual patent agreement and future options.
Nokia will book a gain on the sale of some 3.2 billion euros, which would "clearly strengthen our financial position and it will provide a solid basis for future investment in Nokia's continuing businesses," Siilasmaa said.
NSN, which is specialised in high-speed mobile broadband, was set up as a joint venture between the two companies in 2007, a partnership that expired in April. The unit has posted stronger earnings than Nokia's mobile phone business.
NSN posted a net profit of 8.0 million euros in the second quarter of this year, compared to Nokia's net loss of 227 million euros in the same period.
The sale to Microsoft is expected to be completed in the first quarter of 2014, pending approval by Nokia shareholders and regulatory authorities, Nokia said.
Microsoft chief executive Steve Ballmer meanwhile told reporters in a conference call that Windows Phone was "the fastest growing smart platform today, growing by 78% last year."
"Today's agreement will accelerate our success in smartphones," he added.