Microsoft has written off nearly all the money it spent to acquire Nokia Reuters

Microsoft has posted its largest ever quarterly loss as a $7.5bn (£4.8bn, €6.8bn) writedown on its failed Nokia mobile phone business wiped out its earnings.

The software giant reported a net loss of $3.2bn (£2bn, €2.9bn) for the three months to 30 June, with earnings falling 5% year-on-year to $22.2bn as a result of falling demand for its Windows operating system.

Earnings were also squeezed by the strengthening US dollar, the company said in a statement.

Microsoft shares fell 4% in after-hours trading in New York.

Amy Hood, chief financial officer, said the quarterly results represented "solid progress against our strategic priorities".

Satya Nadella, CEO of Microsoft, said: "Our approach to investing in areas where we have differentiation and opportunity is paying off with Surface, Xbox, Bing, Office 365, Azure and Dynamics CRM Online all growing by at least double-digits.

"And the upcoming release of Windows 10 will create new opportunities for Microsoft and our ecosystem."

Microsoft had first revealed its plan to write off all the money it spent on the Nokia mobile business, which it acquired for $7.2bn in 2013, earlier in July.

Without the Nokia charges, Microsoft said its operating income for the quarter would have been $6.4bn, with earnings per share amounting to $0.62.

Revenue from the Windows operating system and Windows Phone fell 22% and 68%, respectively.

The Redmond-based company said sales of its Xbox gaming console climbed to 1.4 million in the quarter compared to 1.1 million a year earlier, driven mainly by lower prices.

Net profits for the full year nearly halved to $12.2bn.