SAN FRANCISCO—Buttressed by strong hardware sales, Microsoft roundly beat Wall Street expectations Thursday, announcing that fiscal third-quarter revenue grew to $21.7 billion and earnings per share hit 61 cents.

Analysts expected Microsoft to earn 51 cents a share on revenue of $21.07 billion, compared to 68 cents per share on $20.4 billion revenue in the year-ago quarter.

The 6% revenue gain comes despite hurdles that include a 6.7% year-over-year decline in global PC sales, the strong U.S. dollar and the continuing shift to mobile and tablet-based communications.

The news came after Wall Street’s close and the Nasdaq set a new, all-time closing high. Microsoft MSFT jumped 3.8% to $45 in after-hours trading.

Microsoft’s commercial revenue grew 5% to $12.8 billion, led by a 106% leap in cloud revenue. Despite the positive numbers, this was the company’s fifth straight quarter of year-on-year declines.

“Our transformation is about delivering new value to more customers,” CEO Satya Nadella told analysts during an earnings call. “We’ll continue to push forward with big ambitions.”

Although investors’ expectations for Microsoft were low, its buoyant results spotlight growth in unexpected areas, says Colin Gillis, analyst with BGC Partners.

“Microsoft did a great job controlling costs, showed continued growth in enterprise and was even ahead of expectations with hardware, which helped for the second quarter in a row,” says Gillis, referencing the more than $3 billion racked up by phones and tablets. “There could be a whole new story here of Microsoft the hardware company.”

Revenue from the company’s Surface tablets was up 44% to $713 million, while phones generated $1.4 billion. Such devices are seen as integral to Microsoft’s push to become cloud- and mobile-first company. Device and customer revenue combined were up 8% to $9 billion, which includes a 30% jump in Xbox Live usage.

“We would characterize these results as a big step in the right direction for Nadella and Microsoft, and it appears Microsoft is back on the right track after a head-scratching performance last quarter,” says Daniel Ives of FBR Capital Markets. “The Street was expecting a C quarter, they delivered a B+; the bulls will take it.”

Executives were talking to investors and journalists on a conference call. Follow @marcodellacava for live updates.

Ives says investors will want to hear more from Nadella on the continuing rollout of the Windows 10 operating platform and its role as an anchor for Microsoft’s long term strategy. “This flagship release needs to be successful for Microsoft shares to go higher in our opinion and growth depends on it for the coming years,” he says.

Gillis still predicts choppy waters ahead for the Redmond, Wash.-based company, “with some pain points along the way as a result of trying recapture market share at the expense of revenue.” Microsoft is offering free upgrades to its new Windows 10 operating system.

“Microsoft is a big ship to turn around,” says Gillis. “But they’re doing it.”