US stocks closed higher on Friday, with all three major indices posting weekly gains, as investors turned their attention to the upcoming third-quarter earnings reports and inflation data next week. The Dow Jones Industrial Average rose 423.31 points, or 0.83%, to 51,654.95; the S&P 500 gained 46.15 points, or 0.59%, to 7,811.54; and the Nasdaq Composite Index advanced 172.83 points, or 0.64%, to 27,366.17.

Crude oil prices initially pulled back after US President Donald Trump stated that the US would not launch any attacks on Iran before the midterm elections, adding that negotiations aimed at ending the war in Iran were "productive." However, both front-month West Texas Intermediate and Brent crude futures closed up 0.4%. Benchmark government bond yields edged higher but remained below the 24-year high reached on Wednesday.

The third-quarter earnings season will kick off next week, with major US banks including Wells Fargo, Goldman Sachs, Citigroup, JPMorgan Chase, Bank of America, and Morgan Stanley set to report their results. Meanwhile, US consumer sentiment deteriorated this month, with short-term expectations falling to historic lows.

In company news, Elon Musk's SpaceX reached an agreement to acquire a nationwide low-frequency spectrum portfolio, posing a direct challenge to US wireless carriers. Shares of telecommunications companies T-Mobile US, AT&T, and Verizon fell between 8.8% and 13.3%. Apple's stock declined 1.1% after reports that the iPhone maker had told some suppliers to cut component production for its newly launched iPhone 18 Pro and iPhone 18 Pro Max, due to soaring memory chip costs and price increases curbing consumer demand.