It would take time to find a stock that has skyrocketed as much as Nvidia (NVDA 6.18%) has recently. Thanks to heightened interest (or more like a craze) in companies at the forefront of the artificial intelligence (AI), this stock has soared 271% in the last 12 months and a whopping 2,170% just in the past five years.

For those who have watched from the sidelines, it's understandable if you think it's too late to get in on the action. After all, Nvidia is currently a $2.2 trillion enterprise.

But don't be discouraged. Alphabet (GOOGL 10.22%) (GOOG 9.96%), an innovative business at the leading edge of the internet for more than two decades, might just be the best AI stock to buy and hold.

A meteoric rise to the top

Nvidia sells chips that power data centers which support AI functions, and it counts some big tech corporations as its customers. It's OK if the latest financials have you picking up your jaw from the floor. Nvidia reported revenue growth of 126% in 2023. Even more impressive, operating income surged 686%.

This company is looking at a truly massive opportunity. On a global basis, the AI market is forecast to rise 800% by the end of the decade. Based on its financial results thus far, it's hard to deny that Nvidia is in a powerful position to benefit from this tech trend.

Nvidia's monster rise in the last few years has now made it the world's third-most valuable business. And the shares, unsurprisingly, look expensive. They trade at a price-to-earnings (P/E) ratio of 74. That's a lofty valuation, even when you factor in Nvidia's growth prospects.

While it might be tempting to want to ride this momentum to strong portfolio returns, the enthusiasm surrounding the company these days might leave zero margin of safety for prospective investors. There's another compelling opportunity to take advantage of today.

Don't forget about Alphabet

Nvidia deserves credit, that's for sure. But don't sleep on Alphabet. The FAANG stock has dropped 14% since hitting a new all-time high in late January. This means investors can scoop up shares at a compelling P/E multiple of about 23. That seems like a no-brainer decision.

It's best not to forget that this business is one of the early pioneers of AI, introducing the technology in Google Search in 2001. Back then, AI helped users improve their spelling when making search queries.

Alphabet's progress has been notable. In late 2016, CEO Sundar Pichai proclaimed that the company would be "AI-first." This was six years before the famous launch of ChatGPT, which started the AI craze currently underway.

"In the next 10 years, we will shift to a world that is AI-first, a world where computing becomes universally available -- be it at home, at work, in the car, or on the go -- and interacting with all of these surfaces becomes much more natural and intuitive, and above all, more intelligent," Pichai wrote in a blog post more than seven years ago.

The fact that consumers probably don't realize that Alphabet has already integrated AI into its various products and services is indicative of how the business has seamlessly executed its strategy. Whether it's Gmail, Photos, Maps, or YouTube, AI permeates through.

And when it comes to Google Cloud, which is a back-end infrastructure provider to enterprise and government clients, Alphabet has ample opportunity to move the needle forward with AI. There are already numerous features available to customers, be it generative AI, machine learning, language, or other areas.

In the last 24 months, Alphabet generated $203 billion of operating cash flow. And as of Dec. 31, the company had nearly $100 billion of net cash on the books. This puts Alphabet in a league of its own when it comes to having the financial resources to continue investing aggressively in AI capabilities. It will be hard for others to keep up.

Nvidia is getting all the attention these days. But investors need to consider Alphabet as a smart buying opportunity right now. It's in a favorable position to benefit over the long term from the AI boom.