US stocks have rallied to their largest quarterly gain in six years, capping a period of remarkable resilience. The S&P 500 and Nasdaq notched records as investors looked past escalating tensions in Iran and a volatile semiconductor sector.

The rally was fueled by a wave of corporate earnings and renewed enthusiasm for artificial intelligence. A blockbuster IPO from SpaceX also added momentum, drawing billions in capital from institutional investors seeking exposure to space and defense technology.

Qualcomm emerged as a standout, forecasting explosive growth in its data center business over the next three years. The chipmaker attributed the surge to rising demand for its AI inference chips, positioning itself as an alternative to Nvidia and Broadcom in the fast-growing market.

Analysts caution that geopolitical risks and rising interest rates could puncture the rally. The Iran conflict threatens energy supplies, while chip stocks remain prone to export policy shocks and trade tensions between the US and China.

"The market is pricing in a soft landing, but one missile strike could change the calculus overnight," wrote economists at Goldman Sachs. The second half will test whether fundamentals can sustain the momentum.