The S&P 500 finished with its first weekly gain in four weeks Friday as investors welcomed a thaw in the punishing trade war between the U.S. and China.

After two days of negotiations in Washington, the U.S. agreed to suspend a planned hike in tariffs on $250 billion of Chinese goods that had been set to kick in Tuesday. Beijing, meanwhile, agreed to buy $40 billion to $50 billion in U.S. farm products.

Word of the trade concessions filtered out in the last half-hour of trading and pushed the Dow Jones Industrial Average 517 points higher, though the momentum faded near the close.

“The market is welcoming any progress here, because (trade) has been the biggest overhang on growth,” said Ben Phillips, chief investment officer at EventShares. “Any sort of deal, even if it’s a super light, mini-deal, still gets the market constructive and saying, ‘OK, we’re moving in the right direction.’”

The S&P 500 index closed higher for the third-straight day, adding 32.14 points, or 1.1%, to 2,970.27. Earlier it had been up 1.9%. The Dow rose 319.92 points, or 1.2%, to 26,816.59.

The Nasdaq gained 106.26 points, or 1.3%, to 8,057.04. The Russell 2000 index of smaller company stocks outpaced the broader market, climbing 26.54, or 1.8%, to 1,511.90. The indexes all notched gains for the week.