U.S. stocks closed mostly higher Tuesday as investors continued rotating into artificial intelligence firms while largely looking past a sharp rise in oil prices and fresh questions surrounding some of the market's highest-profile growth stories.

The Dow Jones Industrial Average gained 229.58 points, or 0.45%, to 51,308.5, while the S&P 500 rose 9.98 points, or 0.13%, to 7,609.9. The Nasdaq Composite added 7.09 points, or 0.03%, to 27,093.9, finishing near session highs after spending much of the afternoon fluctuating between gains and losses.

The primary driver of Tuesday's trading session was investor conviction that the artificial intelligence spending cycle remains intact and may be accelerating. Market participants continued digesting Hewlett Packard Enterprise's earnings report released Monday evening, which highlighted booming demand for AI infrastructure.

HPE withdrew its 2028 financial targets, citing the rapidly evolving AI landscape and surging customer demand for next-generation computing systems. Rather than viewing the move negatively, investors interpreted it as evidence that AI-related capital expenditures remain in the early stages of expansion.

Energy markets provided a competing narrative. Brent crude oil climbed $0.95, or 1.0%, to $95.93 per barrel, approaching the $96 level as traders focused on refining margins and tightening gasoline markets ahead of the summer driving season. Some analysts increasingly see refiners rather than integrated oil majors as the more attractive way to gain exposure to elevated fuel prices and strong seasonal demand.

Despite higher oil prices, market anxiety eased throughout the day. The CBOE Volatility Index (VIX) fell 0.24 points, or 1.5%, to 15.81, signaling improving investor confidence and reduced demand for portfolio protection.

Investors were also evaluating fresh debate surrounding SpaceX's valuation after Morningstar published research estimating the company could be worth approximately $780 billion, significantly below some private-market expectations associated with a future public offering. The analysis highlighted concerns over governance provisions and shareholder rights that could become focal points should SpaceX eventually pursue an IPO.

By the closing bell, the market's message was clear: investors remain willing to look beyond higher oil prices and valuation debates so long as the AI investment cycle continues generating evidence of robust demand. Attention now turns to earnings reports from Broadcom and CrowdStrike after the bell on Wednesday.