U.S. stocks advanced Friday, bringing a strong week on Wall Street to a close as the S&P 500 approached its all-time high despite continued uncertainty in energy and bond markets.

The S&P 500 rose 0.6%, coming close to the record it set three days earlier. The Dow Jones Industrial Average gained 0.8%, while the Nasdaq Composite climbed 0.6%.

Oil prices fluctuated throughout the session as investors weighed uncertainty surrounding the war with Iran and the potential disruption to global energy supplies. Brent crude, the international benchmark, traded between $102.50 and $105 per barrel before settling at $104.72, up 0.4%.

Treasury yields also swung during the day before the yield on the 10-year Treasury note rose to 5.24%, compared with 5.22% late Thursday. The yield has recently reached its highest level since 2002, reflecting concerns about persistent inflation, the federal government’s enormous debt burden and continued economic growth. Higher Treasury yields can put pressure on stocks by making bonds more attractive to investors while increasing borrowing costs for households and businesses. Mortgage rates have also climbed, with the average rate on a 30-year fixed mortgage reaching its highest level in nearly three years.

Despite those pressures, demand at recent Treasury auctions has helped limit further increases in yields. Bond markets overseas have also experienced rising yields, creating additional competition for investment dollars.

Humana was among Friday’s biggest gainers, surging 12.5% after the health insurer reported encouraging data about its quality ratings relative to competitors in Medicare Advantage plans. Cell tower companies also rallied following an announcement by SpaceX that could reshape competition in the U.S. wireless market. Crown Castle jumped 13.3%, while American Tower gained 8.5%. SpaceX announced a purchase involving low-band wireless spectrum that it said could strengthen its Starlink Mobile service by helping signals penetrate walls and reach indoor customers. The deal still requires regulatory approval.

The prospect of a new competitor rattled established wireless carriers. T-Mobile US shares fell 12.6%, AT&T dropped 10.1% and Verizon declined 9.1%. SpaceX shares gained 0.2%. Delta Air Lines slipped 0.6% after reporting summer revenue and profits that fell short of analysts’ expectations, with the airline facing an estimated $6 billion increase in fuel costs this year.

Investors are now turning their attention to the next round of corporate earnings, with major banks including Citigroup, JPMorgan Chase and Wells Fargo scheduled to report results Tuesday. Inflation remains a concern: a preliminary University of Michigan survey found consumers now expect inflation to reach 4.7% over the coming year, up from 4.6% a month earlier and 3.4% in February before the war with Iran began. Consumer sentiment has weakened particularly among lower-income Americans with smaller stock-market investments.

International markets finished mixed. European stocks advanced, with indexes in France, Germany and the United Kingdom each gaining at least 1%. In Asia, Japan’s Nikkei 225 finished nearly unchanged, while Hong Kong’s Hang Seng Index climbed 1.8%.

Friday’s gains demonstrated Wall Street’s continued resilience, but elevated borrowing costs, volatile energy prices and persistent inflation expectations remain important challenges for investors and American consumers