The first half of the year was a difficult one for many artificial intelligence (AI) stocks as investors fled high-growth players. The reason? They worried that President Donald Trump's import tariff plan might lift prices for a wide range of goods -- and this could hurt the consumer's buying power, weigh on corporate expenses, and eventually stop growth companies in their tracks.

As a result, the S&P 500, the Dow Jones Industrial Average, and the Nasdaq Composite slid in April, but in recent weeks, investor sentiment has improved. Initial trade deals with the U.K. and China helped, as did commentary from tech giants, who reiterated capital spending plans, suggesting that potential tariffs wouldn't stop their momentum.

Though the tariff situation remains uncertain, the market's more sanguine view, as well as certain companies' solid long-term outlooks, make now a fantastic time to get in on AI stocks. And two in particular may be well positioned to soar in the second half.

An investor cheers behind a laptop.

Image source: Getty Images.

1. Amazon

The best word to describe Amazon's (AMZN 1.26%) stock performance in the first half is "lackluster." The company actually finished the half at the same level it started, posting a 0% move for the period. Investors may have been concerned about Amazon getting hit by tariffs in two ways: Higher prices may weigh on e-commerce demand and revenue, and Amazon Web Services (AWS) might see customers rein in spending.

But there's reason to believe those problems won't occur. Amazon has a wide selection of products and sourcing countries, making it easy for the company to be nimble in an import tariff environment. As for AWS, so far, the strong spending message from companies suggests customers are sticking by their AI strategies and aren't slowing down.

I also like the idea that Amazon has proven its ability to handle difficult environments. A few years ago, when inflation was soaring, the company revamped its cost structure. That move had immediate results, helping Amazon recover from its first annual loss in about a decade. This new cost structure should also make it easier for the company to overcome future pressures on costs, such as import tariffs.

AMZN Net Income (Annual) Chart

AMZN Net Income (Annual) data by YCharts.

Finally, AI infrastructure buildout continues, and AWS, as the world's biggest cloud company, should benefit as its customers seek compute and other AI solutions. This should keep Amazon's billion-dollar earnings growing. And that, as well as a valuation of 35 times forward earnings estimates, down from more than 40 times late last year, could prompt investors to pile into this stock in the second half.

2. Alphabet

Alphabet (GOOG 1.47%) (GOOGL 1.46%) stock slipped more than 6% in the first half of the year amid the general uncertainties I mentioned above. It's on the rebound from its lowest point in April, having gained more than 20% since, and I think the stock will move considerably higher in the months to come amid the improving sentiment for growth players.

Like Amazon, Alphabet is a market leader that has proven itself over time, generating significant growth and billions of dollars in earnings. This is thanks to the company's Google platform and its cloud computing business, Google Cloud. The Google platform brings in revenue through advertising, as advertisers flock to the world's internet search leader to reach us where they know we'll be, and Google Cloud's wide range of services is also a billion-dollar revenue driver.

And AI is at the center of the story right now. The company has developed its own large language model (LLM), and this is fueling better search experiences for users and more targeted ad campaigns for advertisers. Both of these elements should keep advertisers spending, and even increasing spending, on Google.

As for Google Cloud, AI products and services have been driving growth, and the unit reported a 28% increase in revenue to more than $12 billion in the latest quarter. This momentum should continue as cloud customers develop and scale up their AI programs, as we're still in the early days of the AI story.

What may particularly attract investors to Alphabet right now is its dirt-cheap valuation, trading for only 18 times forward earnings estimates. And that could help this top AI stock to roar higher in the second half of 2025.