For about a year now, semiconductor powerhouse Nvidia and cloud computing giant Microsoft have been trading places for the most valuable company in the world. But as Nvidia inches closer to the coveted $4 trillion milestone, it might seem like the company is leaving its "Magnificent Seven" peers in the dust.

Although Nvidia currently holds the title for the most valuable company, I think e-commerce and cloud infrastructure specialist Amazon (AMZN 1.26%) has a better shot at becoming the larger company in the long run.

Let's explore the variety of ways that Amazon is already leveraging AI across its business and detail why the company's robust growth prospects could lead to a considerable expansion in valuation over the next five years.

How can AI help usher in a new wave of growth for Amazon?

Amazon's ecosystem spans e-commerce, logistics, consumer electronics, cloud computing, advertising, streaming, and much more. While AI has the potential to add value to each of these services, I think investors should hone in on how the technology could ignite significant growth across the cloud and e-commerce segments in particular.

Amazon derives the majority of its revenue from online sales, which generated a whopping $250 billion over the last year. Factors such as commoditized product offerings, expensive transportation infrastructure at global scale, and fluctuating shopping patterns from consumers make the e-commerce business a relatively low-margin business for Amazon, though.

Management has expressed intentions to make this area of the business more profitable by leveraging AI-powered robotics. Robotics can be integrated in Amazon's warehouses to help automate mundane tasks alongside the human labor force. In addition, CEO Andy Jassy has even expressed that robots could assist in transportation and delivery of packages down the road.

Per a recent analysis from Morgan Stanley, robotics could help reduce costs by 25% in an individual warehouse. Considering Amazon has global scale, these cost reductions could theoretically expand profitability in e-commerce operations by billions in the long run.

Regarding its cloud business, Amazon has invested $8 billion into a start-up called Anthropic over the last couple of years. Anthropic's services have been swiftly integrated into Amazon Web Services (AWS), and its impact on the business' sales and profitability are already quite significant.

AWS revenue and operating income over the last 12 months.

Image source: Amazon Investor Relations.

Why Amazon's valuation looks poised to expand more than Nvidia or Microsoft in the long run

For much of the last couple of years, Nvidia's graphics processing units (GPUs) have been considered the gold standard for generative AI development. And while many of the Magnificent Seven companies are Nvidia's largest customers today, these dynamics may shift in coming years.

Although Nvidia and Microsoft are valued at premiums right now, I think both companies could struggle to fend off competition in the chip and cloud arenas.

AMZN PE Ratio (Forward) Chart

AMZN PE Ratio (Forward) data by YCharts

Microsoft's partnership with OpenAI may not be as lucrative as it once was, given the ChatGPT maker has been exploring partnership opportunities with Alphabet and Oracle as of late.

In addition, Amazon, Microsoft, and Alphabet are all investing significant capital in their own custom silicon development. Moreover, Advanced Micro Devices has built formidable data center and AI chip businesses that compete directly with Nvidia.

Amazon appears to be witnessing a degree of expansion based on the forward price-to-earnings (P/E) trends pictured above. To me, this signals that investors may finally be understanding that Amazon is uniquely positioned to further monetize its various service offerings by augmenting its ecosystem with AI.

Hence, the company's market cap could rise considerably relative to its peers in the following years as AI becomes the core pillar supporting Amazon's transformation.

A bar chart showing growth over a long time period.

Image source: Getty Images.

Is Amazon stock a buy right now?

Although Amazon stock isn't a bargain now, I still see it as a compelling buy-and-hold opportunity for long-term investors. I do not think the upside that AI carries has been fully baked into the stock price, despite some noticeable expansion in recent months.

Considering the long-term accretive impacts AI could generate for Amazon's core e-commerce and cloud businesses, I think the company is in the early phases of a new growth chapter featuring accelerating revenue and profits for years to come.

For this reason, I think investors could continue valuing Amazon at a premium relative to its peers and see the company emerging as the most valuable business in the world over its AI peers by early the next decade.