(Reuters) - Wall Street edged lower on Friday, as U.S. Vice President Mike Pence’s decision to defer a speech on China policy increased optimism on upcoming trade talks between Washington and Beijing, while tensions between the United States and Iran undercut sentiment.

The S&P 500 briefly hit a record high.

Pence called off a planned China speech that had been cast initially as a sequel to a blistering broadside he delivered in October, a move aimed at averting increasing tensions with Beijing, a White House official said.

The benchmark S&P 500 index hit an intraday record high of 2,964.15, but then stepped back as the rising tensions between the United States and Iran kept investors on edge.

Top for investors next week, U.S. President Donald Trump and Chinese President Xi Jinping are expected to restart trade talks at the Group of 20 summit in Japan on June 28-29.

“People will be focusing on what happens at the G20 with Presidents Trump and Xi,” said Kurt Brunner, portfolio manager with the Swarthmore Group in Philadelphia. Any indication of progress from Trump following the meeting would be positive for Wall Street, he said.

Stocks logged a third straight week of gains after posting their worst monthly performance this year in May on fears the prolonged trade war would hit global economic growth.

Trump said on Friday he aborted a military strike on Iran in response to Teheran’s downing of a U.S. drone, but the possibility of a U.S. retaliation pushed crude prices higher and helped lift the energy sector by 0.82%. [O/R]

The Dow Jones Industrial Average dipped 0.13% to end at 26,719.13 points, while the S&P 500 lost 0.13% to 2,950.46. The Nasdaq Composite dropped 0.24% to 8,031.71.

The tech-heavy Nasdaq was weighed down by a 2.2% fall in PayPal Holdings Inc after the digital payments company said its chief operating officer, Bill Ready, would step down.

For the week, the S&P 500 climbed 2.20%, the Dow added 2.41% and the Nasdaq rose 3.02%.

During Friday’s session, CarMax Inc rose as much as 3.2% to a record high after the used-vehicles retailer posted quarterly results above analysts’ expectations.

Carnival Corp fell for a second day, down 4.4%, and among the biggest decliners. Several brokerages trimmed their share price targets after the cruise operator cut its 2019 profit forecast.

Reflecting “quadruple witching,” as investors unwind interests in futures and options contracts prior to expiration, volume on U.S. exchanges hit 8.6 billion shares, compared with the 7.0 billion-share average for the full session over the last 20 trading days.

Declining issues outnumbered advancing ones on the NYSE by a 1.63-to-1 ratio; on Nasdaq, a 1.63-to-1 ratio favored decliners.

The S&P 500 posted 48 new 52-week highs and 2 new lows; the Nasdaq Composite recorded 64 new highs and 65 new lows.