Microsoft Corp. said its earnings improved from a year earlier, with adjusted profit topping Wall Street's estimates, despite a decline in revenue.

Shares rose 5% to $50.42 in after-hours trading.

This marks the first quarter that the Redmond, Wash., company reports its financial results based on three operating divisions as it aims to emphasize its mobile and cloud businesses. Microsoft and other tech firms have turned their focus to cloud-based products as demand for personal-computers has slumped.

Chief Executive Satya Nadella said in prepared remarks Thursday that the company was "making strong progress across each of our three ambitions."

For the period ended Sept. 30, Microsoft reported a profit of $4.62 billion, or 57 cents a share, up from $4.54 billion, or 54 cents a share, a year earlier.

On an adjusted basis, earnings were 67 cents a share compared with 65 cents in the year-earlier quarter.

Revenue decreased 12% to $20.38 billion, and was $21.7 billion on an adjusted basis.

Analysts polled by Thomson Reuters had expected per-share profit of 59 cents and revenue of $21.03 billion.

Gross margin rose to 64.6% from 64.3%.

Microsoft recently unveiled new products largely aimed at the consumer market--including its first laptop computer, the Surface Book--as well as an updated tablet and two high-end smartphones that aim to help turnaround its struggling mobile-phone business.

Microsoft's Windows smartphones have a tiny share of the market. For the fourth quarter ended in June, Microsoft took roughly $8.4 billion in write-downs and other charges related to the handset business it acquired from Nokia and said it would reduce its global workforce by an additional 7,800 people. Microsoft also plans to more sharply focus its smartphone offerings, rather than targeting the mass market, as it aims to curb losses in the business.

The company has also worked to generate sales from its Windows 10 operating system, which it is giving away free. The company is aiming to garner revenue by selling related apps, videogames, Web-search ads and other add-ons, regardless of whether Windows 10 spurs people to buy updated PCs.

Write to Tess Stynes at tess.stynes@wsj.com

Subscribe to WSJ: http://online.wsj.com?mod=djnwires