Nokia Oyj, the world's largest phone maker by volume, posted better-than-expected quarterly profit thanks to a major royalty boost from settling a patent dispute with Apple.

Nokia reported a second-quarter underlying operating profit of 391 million euros, above all expectations in a Reuters poll, which ranged from a loss of 35 million to profit of 285 million.

Shares in Nokia were 7 percent higher by 1050 GMT.

Nokia said it sold 16.7 million smartphones in the quarter, losing its position as the largest smartphone manufacturer to Apple, which sold 20.3 million iPhones in the quarter.

The Finnish company created the smartphone market in 1996 with its first Communicator model, but has failed in recent years to find an answer to the surge from Apple Inc's iPhone and Research In Motion's BlackBerry.

Nokia Chief Executive Stephen Elop has been pinning turnaround hopes on new smartphones using Microsoft software, but these will only come to market later this year.

Nokia's share price had halved since February, when it unveiled the shift to Microsoft, on worries the company will lose so much market share before the new phones come out that it might never make up lost ground.

(Editing by Will Waterman)