Oil prices rallied above $104 a barrel Monday after President Donald Trump said the U.S.-Iran ceasefire was on “life support,” signaling to markets that the costly war would drag on. The remark overshadowed a U.S. stock market that nevertheless edged to fresh records, as a flood of corporate earnings beat expectations and technology shares kept climbing.

Brent crude, the international benchmark, settled at $104.21 a barrel, up 2.9 percent on the session. Trump made the remarks while rejecting Iran’s latest proposal to end the war, according to the Associated Press. He was also due to travel to China this week where he planned to urge President Xi Jinping to squeeze Iran, which depends on China as the largest buyer of its sanctioned crude.

The war has already sent Brent prices up from roughly $70 a barrel and choked off tanker traffic through the Strait of Hormuz, leaving millions of barrels stuck in the Persian Gulf and draining global supply.

Nevertheless, U.S. stocks have set a run of records on bets that the conflict will not keep oil prices elevated for long. On Monday, the S&P 500 added 0.2 percent, lifting the index to 7,412.84. The Dow Jones Industrial Average rose 95 points to 49,704.47, and the Nasdaq composite gained 0.1 percent to 26,274.13 — all all‑time highs.

Strong corporate earnings extended a breakneck streak: more than four out of five S&P 500 companies that have reported results so far have beaten Wall Street’s profit forecasts, according to FactSet. Overall profit growth is on pace for nearly 28 percent — the best since the fourth quarter of 2021. Strategists at Deutsche Bank, led by Binky Chadha, noted that global earnings were also on track for their strongest growth in more than four years, fueled by the artificial‑intelligence technology boom.

That AI theme continued to buoy markets. Chipmaker Nvidia gained 2 percent and Micron Technology climbed 6.5 percent, providing the strongest upward thrust within the S&P 500. Fox rallied 7.6 percent after posting revenue and profit that easily topped estimates.

But the war’s toll was evident in corners of the market that can’t easily absorb higher energy costs. Dollar General tumbled 7.6 percent, Royal Caribbean slid 4.3 percent, and Southwest Airlines fell 3.2 percent as fuel and logistics expenses ate into their margins. Mosaic, the fertilizer company, dropped 1.8 percent after reporting weaker results than analysts expected, partly because the war had driven up costs for sulfur and other raw materials.

On the deal‑making front, Beazer Homes USA soared 34 percent after Dream Finders Homes offered to acquire the homebuilder in a deal worth about $704 million. If completed, the combination would create the country’s seventh‑largest homebuilder. Dream Finders rose 5 percent.

Overseas, equity indexes were mixed. South Korea’s Kospi surged 4.3 percent, propelled by Samsung Electronics, SK Hynix and other tech names riding the AI wave. European markets mostly edged lower; France’s CAC 40 slipped 0.7 percent.

In the bond market, the yield on the 10‑year U.S. Treasury note ticked up to 4.40 percent, from 4.38 percent late Friday. Higher yields have pushed up borrowing costs for mortgages and other loans, weighing on the housing market. A separate report Monday showed that the pace of sales for previously occupied U.S. homes was weaker last month than economists had projected.

Associated Press reports contributed to this article.