If the question of which was the better stock to buy, Microsoft (NASDAQ:MSFT) or IBM (NYSE:IBM), was asked of investors a year ago, the likely answer would have been "neither." Microsoft was picking up the pieces of its failed smartphone manufacturing mess following the write-off of $7.5 billion as a "non-cash impairment charge," along with another $940 million attributed to restructuring charges.

IBM's stock was still reeling from the dying PC and old-school enterprise hardware markets, while CEO Ginni Rometty finally confessed the company's 2015 Roadmap plan of reaching $20 a share in earnings for the year was never going to happen. But the tables have since turned in the right direction for IBM and Microsoft, which translates to a compelling argument for both tech titans.

Image source: IBM.

The case for IBM

IBM continues to make headway in its all-important strategic-imperatives initiative, which includes the cloud, analytics, cognitive computing, mobile, and data security. Rometty has bet the IBM farm on successfully making the transition to these fast-growing markets, and for good reason.

According to tech research firm Gartner, public cloud services will generate $204 billion in revenue this year, and by virtually every estimate, that's just the tip of the cloud iceberg. The better news for IBM is where the majority of all those cloud-related sales are expected to come from: managed business services and Software as a Service (SaaS).

Combined, managed services and SaaS solutions delivered via the cloud will account for over $80 billion in sales in 2016 -- and both areas are right up IBM's alley. Sure, IBM has its SoftLayer cloud platform, but that's simply a means to an end -- the "end" being cognitive computing, security, and data analytics services to help its customers make sense of, and ultimately utilize, all the data collected in today's connected world.

Rometty's execution on IBM's strategic imperatives -- the company has already made 11 acquisitions totaling more than $5 billion in 2016 -- is actually ahead of schedule. The plan was for IBM to derive 40% of its total sales from strategic imperatives by 2018. As of the second quarter of this year, combined revenue from strategic imperatives jumped 12%, and the $30.7 billion annual run rate already equates to 38% of total sales.

Image source: Microsoft.

The case for Microsoft

Just like IBM's Rometty, Microsoft CEO Satya Nadella has tied nearly all of his company's fortunes to the cloud -- and it's working. Microsoft is one of the few companies on the planet that can boast an annual cloud revenue run rate higher than IBM's: over $12.1 billion, compared to "just" $11.6 billion for Rometty and team. And it's Microsoft's SaaS suite of solutions that is driving the company's cloud success.

While the 102% year-over-year increase in Microsoft's Azure cloud platform revenue last quarter was impressive, in the long run it takes a back seat to the company's SaaS sales. Microsoft's flagship Office 365 commercial sales jumped a whopping 54% year over year last quarter, and its consumer cloud and Office sales climbed 19%.

Though Microsoft made the painful but necessary decision to exit the smartphone manufacturing business, hardware sales are still humming along thanks to the successful introduction of its Surface -- the "tablet that can replace your laptop" -- and skyrocketing Xbox usage. Surface revenue improved by 9% last quarter, and the number of Xbox active users jumped 33%, to a mind-boggling 49 million.

Microsoft also has up its sleeve another revenue opportunity that sometimes gets lost in the cloud discussion: HoloLens. Though the holographic device is not quite ready for prime time, Microsoft has opened the door to developers to help get HoloLens ready for the masses -- and the masses could prove to be huge. According to one report, of the $120 billion in sales virtual reality (VR) and augmented reality (AR) are expected to generate by 2020, $90 billion will come from AR devices, led by Microsoft's HoloLens.

Both Microsoft and IBM pay a more-than-respectable dividend -- 2.5% and 3.5%, respectively -- and both are on the leading edge of the next big thing, the cloud. So which is the better buy? IBM gets the nod primarily because of its relative value: It's trading at just 13 times future earnings, compared to Microsoft's 18. That said, both up-and-comers offer investors a world of opportunity.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.