Microsoft posted its first quarterly loss in its 26 years as a public company as it declared a struggling online ad business a bust and prepared for one of the biggest product updates in its history.
The software giant had warned two weeks ago that it would take a $6.2bn (£3.9bn) charge in the April-June quarter because its 2007 purchase of online ad service aQuantive failed to help it compete with Google. The amount reflected the bulk of the $6.3bn (£4bn) acquisition cost.
The online ad business remains just a tiny part of Microsoft - comprising just 4% of its annual revenue. Most of the company's sales come from its Office suite of productivity software, Windows operating system and, increasingly, computer servers.
Upbeat business software and server sales in the quarter helped offset a flat market for personal computers, which had put a damper on Windows sales. Take as a whole, the software giant's results beat analyst expectations.
Shares rose 2.4% to $31.39 in after-hours trading following the earnings announcement.
Including the big write-down on aQuantive, Microsoft booked a $492m (£313m) loss in the fiscal fourth quarter, or 6 cents a share. That compares with earnings of $5.9bn (£3.7bn), or 69 cents, a year ago.
Revenue rose 4 % to $18.06bn (£11.5bn).
Excluding the adjustment and the deferral of some revenue related to its upcoming Windows 8 operating system, earnings came to 73 cents per share.
Analysts polled by FactSet were looking for 62 cents per share of earnings on revenue of $18.15bn.
"The quarter was pretty much in line across major segments of the business," Nomura analyst Rick Sherlund said.
Microsoft's fortunes are now tied to the October 26 release of Windows 8, the most extreme redesign of the company's flagship operating system since 1995.
Windows 8 will feature a new look and boast new technology that will enable the operating system to work on touch-controlled tablet computers, as well as Microsoft's traditional stronghold of desktop and laptop computers.
In conjunction with Windows 8, Microsoft is planning to release its own tablet, the Surface.
A revamped version of Office, which bundles word processing, spreadsheet and email programmes, is also in the works.
Yesterday's loss was the first for Redmond, Washington-based Microsofit since the company went public in March 1986.
The $6.2bn charge is a non-cash adjustment, which companies do when the value of their assets decline. Firms have to review their assets once a year, and the just-ended quarter is Microsoft's final one for fiscal 2012.
AQuantive was Microsoft's most expensive purchase at the time and was supposed to help it mount a more serious challenge to Google in online ads.
But the online ad division continued to post losses - totaling more than $9bn (£5.7bn) since the purchase, not including the charge.
By contrast, Google has widened its lead, thanks in part to its purchase of DoubleClick for $3.2bn (£2bn) about eight months after the aQuantive deal.
Google's search engine, a major vehicle for selling ads, has remained strong, while Microsoft's Bing search engine saw its market share drop slightly to 26%, from 27% a year ago. That includes searches through Yahoo, which has been using Microsoft's search technology for nearly two years.
Google earned $2.8bn (£1.7bn), or $8.42 per share, during the three months ending in June. That compared with net income of $2.5bn, or 7.68 per share, last year.
Revenue climbed 35% from last year to $12.2bn (£7.7bn).