Bye-bye, bear market? The S&P 500 only briefly entered bear market territory in June. The Nasdaq Composite Index stayed in a bear market longer. However, it's now up 20% from the low -- a criterion that some use to determine when a bear market is over.

The bottom line is that the stock market has been on a roll in recent weeks. And some stocks that are playing a bigger role in this momentum than others look like great picks right now. Here are two Warren Buffett stocks to buy that are especially helping drive the market rebound.

Key drivers

Apple (AAPL -0.67%) ranks by far as the top stock that Buffett owns other than Berkshire Hathaway (BRK.A 0.37%) (BRK.B 0.28%) itself. The tech stock makes up more than 40% of Berkshire's portfolio.

Amazon (AMZN -1.24%) isn't nearly as high on the list for Buffett. Berkshire owns nearly 10.7 million shares of the e-commerce and cloud giant. However, that's enough to comprise only 0.4% of the conglomerate's portfolio. 

Both of these Buffett stocks, though, play an outsized role in driving the S&P 500's performance. The index uses market cap to determine the weighting of each of its component stocks.

Apple's market cap of more than $2.7 trillion makes it the No. 1 stock in the S&P 500 with a weight of 7.3%. Amazon's market cap of $1.4 trillion puts it at No. 3 in the index with a weight of nearly 3.5%.

With Apple and Amazon together comprising almost 11% of the S&P 500's total weight, it's not surprising that the index is much more likely to move higher when both stocks soar. That's exactly what's happened in recent weeks.

Apple stock has jumped 17% over the past month. It's up more than 30% since hitting a 52-week low on June 16, 2022.

Meanwhile, Amazon stock has vaulted 26% higher over the past month. Amazon reached its nadir on June 14, 2022, and has rebounded nearly 40% since then.

Why they're great picks now

Just because Apple and Amazon have great momentum going doesn't mean they're great picks now. But I think they are both great picks for two reasons. First, the near-term prospects for both companies are improving. Second, Apple's and Amazon's long-term prospects continue to be exceptional.

Apple CFO Luca Maestri said in the company's recent quarterly call that "revenue growth will accelerate" in the next quarter. The company also tends to perform really well in Q4 thanks to holiday buying.

Amazon reported record Prime Day sales, which should significantly boost its Q3 results. The company's Prime Video debuts Thursday Night Football and The Lord of the Rings: The Rings of Power in September. Amazon Web Services (AWS) continues to win big new contracts.

I'm even more pumped about the companies' long-term opportunities. For Apple, augmented reality and digital payments appear to be especially important growth markets. I also suspect the company will become a bigger threat in streaming with Apple TV+.

AWS will almost certainly remain a significant growth driver for Amazon. Don't overlook the potential for company's recently announced acquisitions, though, to make a big difference. Amazon's buyout of One Medical will bolster its presence in the healthcare market. I also totally agree with the view that Amazon's acquisition of iRobot is about a lot more than just vacuums. It will be intriguing to see how the home robotics market evolves with Amazon in the driver's seat.

Some risks

Sure, both Apple and Amazon face some risks. It's possible that a severe economic downturn could still happen. Supply chain issues could still negatively impact both companies. They also might be derailed by innovative competitors in some markets.

However, these two Buffett stocks continue to rank among the best-run businesses with strong moats and multiple avenues to generate growth. If the market rebound has legs, it will probably be in large part to sustained momentum for Apple and Amazon.