Shares rose 3.1 percent to $44.70 in after-hours trading.
"The company beat across the board," said FBR Capital markets analyst Daniel Ives. "The Street will cheer these results as it appears Microsoft is back on the right track after a head-scratching performance last quarter."
Sales of Windows to computer manufacturers to install on new PCs fell 19 percent in the quarter, reflecting a sharp dip from a year ago when Windows got a brief boost from consumers rushing to buy new machines after Microsoft stopped support for the 14-year-old XP operating system.
That decline was offset by higher revenue from its Surface tablet, back-end server software and cloud-related offerings such as its online Office 365 suite of applications.
The company said its commercial cloud-related revenue for the quarter more than doubled, and was now running at $6.3 billion a year. Amazon said on Thursday its quarterly cloud revenue rose almost 50 percent to $1.57 billion, suggesting a similar annual number.
Microsoft's overall revenue rose 6 percent to $21.7 billion, above Wall Street's average forecast of $21.1 billion, according to Thomson Reuters I/B/E/S.
Taking out the effects of the strong U.S. dollar on currency rates, Microsoft said revenue would have risen 9 percent.
Earnings per share declined to 61 cents per share from 68 cents in the year-ago quarter. Analysts had expected 51 cents, on average.
© Thomson Reuters 2015
For the latest tech news and reviews, follow Gadgets 360 on X, Facebook, WhatsApp, Threads and Google News. For the latest videos on gadgets and tech, subscribe to our YouTube channel. If you want to know everything about top influencers, follow our in-house Who'sThat360 on Instagram and YouTube.