LOS ANGELES (AP) -- Microsoft posted its first quarterly loss in its 26 years as a public company on Thursday as it declared a struggling online ad business a bust and prepared for one of the biggest product updates in its history.
The software company had warned two weeks ago that it would take a $6.2 billion charge in the April-June quarter because its 2007 purchase of online ad service aQuantive failed to help it compete with Google Inc. The amount reflected the bulk of the $6.3 billion acquisition cost.
The online ad business remains just a tiny part of Microsoft — comprising just 4 percent 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. Taken as a whole, the software giant's results beat analyst expectations.
Shares rose 2.4 percent to $31.39 in after-hours trading following the earnings announcement.
Including the big write-down on aQuantive, Microsoft booked a $492 million loss in the fiscal fourth quarter, or 6 cents a share. That compares with earnings of $5.9 billion, or 69 cents, a year ago.
Revenue rose 4 percent to $18.06 billion.
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.15 billion.
"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 Oct. 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 programs, is also in the works. Earlier this week, Microsoft previewed how the next version of Office will work on tablet computers running on Windows 8.
The company was conservative forecasting how much the product revamps will help drive revenue.
Chief Financial Officer Peter Klein told analysts that for the coming year, "We expect Windows revenue to be roughly in line with the PC market" which it said was flat in the last quarter and is expected to continue that way in the three months through September.
Even if Windows revenue is flat, that will be an improvement since revenue in the division has now dropped in five of the past seven quarters. It fell 13 percent in the quarter to $4.1 billion.
Microsoft excluded from its forecast any extra Windows sales that would come from its Surface tablet, for which it gave no outlook.
With Windows 8-powered devices still a few months away, some prospective PC buyers have been postponing their purchases so they can buy the latest technology from Microsoft this fall. Others who buy certain machines running Windows 7 will be able to upgrade to Windows 8 for $15 for a limited period.
That upgrade offer means that Microsoft couldn't book all the revenue associated with Windows 7, causing it to defer some revenue into later quarters.
Thursday's loss was the first for Redmond, Wash.-based Microsofit since the company went public in March 1986.
The $6.2 billion charge is a non-cash adjustment, which companies do when the value of their assets decline. Companies 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 $9 billion since the purchase, not including the charge.
By contrast, Google has widened its lead, thanks in part to its purchase of DoubleClick for $3.2 billion 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 percent, from 27 percent a year ago. That includes searches through Yahoo Inc., which has been using Microsoft's search technology for nearly two years.