Nokia said it expected its struggling cellphone business to remain profitable in the third quarter, bringing some relief to investors after it lost its lead in the smartphone market to rival Apple.

Nokia, the world's largest phone maker by volume, reported a second-quarter underlying operating profit of 391 million euros ($555.1 million), above all analysts' forecasts, which ranged from a loss of 35 million to profit of 285 million in a Reuters poll.

The results were boosted by royalty revenues of 430 million euros in the quarter, including payments from Apple following settlement of a legal dispute.

Analysts had expected the phone business to weaken further in the third quarter and to report an underlying operating result around breakeven, and many said the company's outlook to be slightly above breakeven was comforting.

The guidance for the third quarter was a relief. It seems it will not be as bad as was feared, said Hannu Rauhala, analyst at Pohjola Bank.

Shares in Nokia were up 3.6 percent at 1115 GMT, giving up some of its initial gains.

LOSING SMARTPHONE CROWN

Nokia said it sold 16.7 million smartphones in the quarter, falling behind Apple's sales of 20.3 million iPhones.

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.

The path to recovery for Nokia is going to be a long one. Deterioration in Nokia's smartphone performance shows that time is of the essence in rebuilding a coherent portfolio of Windows Phone 7 products in 2012, said CCS analyst Geoff Blaber.

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)