Apple (NASDAQ:AAPL) and Microsoft (NASDAQ:MSFT) have been battling for supremacy in the personal computer market for a long time, and both rivals can claim victories.

Apple has become one of the world's top brands by locking customers into its ecosystem spanning devices and services. On the other side, Microsoft has been known for its dominance in software with Windows and Office, and the software giant has recently emerged as one of the largest cloud providers, which should be a key source of growth for the company going forward.

Let's find out which stock investors should buy today.

A light bulb sitting on a stack of coins with a trail of coins leading off to the left.

IMAGE SOURCE: GETTY IMAGES.

A rising services giant

Apple is the second most valuable brand in the world, just behind Amazon.com, according to Brand Finance. There are 1.3 billion Apple devices active around the world, and around 500 million people visit an Apple store every year. That brand loyalty has translated to life-changing returns for investors over the past decade, with Apple stock up 1,280%. 

But the stock is down 22% over the past three months, as investors have become concerned about slowing sales of the iPhone, which made up 59% of total revenue in the third quarter. To combat a stagnant smartphone market, Apple is transitioning to a growth strategy that's centered more on price increases and growing revenue from services such as Apple Pay.

Apple was able to grow iPhone revenue 29% in the fourth quarter, despite no increase in unit sales. Strong iPhone X sales drove a 29% year-over-year increase in average selling price -- a testament to Apple's brand power. The quarter only represented a few weeks' worth of sales results from the iPhone XS launch.

As for services, Apple Pay has experienced triple-digit growth in transaction volume year over year.  Overall, revenue derived from services, including Apple Music, iCloud, AppleCare, App Store, and Apple TV, grew 24% in fiscal 2018, which ended in September.

Meanwhile, revenue generated from other products and accessories, including Apple Watch, Beats headphones, and AirPods, grew 31% year over year in the fourth quarter, good enough to make it Apple's fastest-growing category. 

Analysts expect Apple to grow earnings 13% annually over the next five years. The stock trades at just 12 times next year's earnings estimates and offers a 1.51% dividend yield. 

AAPL Revenue (TTM) Chart

AAPL Revenue (TTM) data by YCharts

A rising cloud giant

Similar to Apple, Microsoft is making its own pivot to faster-growing areas and is seeing great results. The software giant is coming off a fantastic year in which revenue growth accelerated to 14% in fiscal 2018, which ended in June. The stock is up 32% over the past year, as investors are getting increasingly optimistic about the company's growth prospects in the fast-growing cloud market. 

Microsoft was late to the cloud party, but the company now holds the No. 2 market share spot in the cloud market, although it's still way behind Amazon Web Services. In the first quarter, the company's intelligent cloud division grew revenue 24%, driven by 76% growth in Microsoft's Azure, which follows 91% growth in fiscal 2018. Microsoft has some of the biggest companies in the world using its cloud and artificial intelligence technology, including Coca-Cola, Chevron, Mastercard, and Walmart, among several other household names. 

In addition to the cloud, Microsoft is successfully transitioning to a subscription-based model of distributing its office software suite for enterprise and consumers. Revenue from the Productivity and Business Processes division, which includes Office 365 subscriptions, grew 19% in the first quarter. This also includes revenue from LinkedIn, the social network for working professionals, which saw revenue grow 33%.

The company also continues to invest in other growth opportunities, such as gaming and its HoloLens virtual-reality technology. HoloLens just won a contract from the U.S. Army, but it has yet to gain meaningful traction in the consumer market. Microsoft's gaming business, meanwhile, just crossed $10 billion in annual revenue in fiscal 2018, as Xbox reached 57 million monthly active users, although Microsoft continues to trail behind Sony's PlayStation, which has vastly outsold the Xbox One in the current console generation. 

Analysts expect Microsoft to grow earnings 14% annually over the next five years. The stock trades at 22 times next year's earnings estimates and offers a 1.79% dividend yield. 

Which is the better buy?

Even though both companies are expected to grow earnings at about the same rate, Microsoft deserves to trade at a higher valuation than Apple, because of the software giant's reliance on more reliable streams of revenue, such as cloud spending and subscription services. Corporations will probably continue to invest in cloud services no matter what the economy is doing.

On the other hand, Apple is still mostly reliant on selling pricey gadgets to consumers who may put off upgrading their iPad or iPhone if the economy slows down. Over time, though, services could become a much bigger contributor to Apple's top line, which would make the company less dependent on hardware sales.

But leaving Apple's iPhone dependency aside, there is currently a fairly large valuation gap between the two stocks. Microsoft's forward P/E of 22 looks justified relative to its underlying growth. But Apple's forward P/E of 12 looks too attractive to pass up.

Apple's shares trade at a discount to the S&P 500 index's forward P/E of 16.7 -- an average of many household-name companies. Plus, at $123 billion, Apple has about twice as much net cash on its balance sheet as Microsoft, and the iPhone maker generated $64 billion in free cash flow over the past year. Apple has plenty of resources to reward shareholders through a combination of dividends and share repurchases.

I don't think investors can go wrong with either stock, but I'd go with Apple at current market prices.