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.

Treasury yields rose as investors felt less need for safety and dumped bonds. The yield on the 10-year Treasury, a benchmark for mortgages and many other kinds of loans, jumped to 1.73% from 1.65% late Thursday.

The rally got going early, reflecting optimism among investors that Washington and Beijing would reach at least a limited deal on trade. The U.S.-China trade dispute has been a drag on economic growth and slowed manufacturing around the world.

The concessions agreed upon by the U.S. and China Friday mark a sharp turnaround after expectations were lowered earlier in the week when the U.S. blacklisted a group of Chinese technology companies over alleged human rights violations.

The Trump administration has already raised tariffs on more than $360 billion worth of Chinese imports, but the stakes were set to rise. The U.S. had planned to raise tariffs on $250 billion in Chinese imports from 25% to 30% Tuesday. Those are now suspended. But the two sides did not mention tariffs on $160 billion of goods scheduled for Dec. 15.

A missile strike on an Iranian tanker revived concerns about oil supplies and pushed energy prices higher. 

Benchmark crude oil rose $1.15 to settle at $54.70 a barrel. Brent crude oil, the international standard, gained $1.41 to close at $60.51 a barrel. 

In other commodities trading Friday, wholesale gasoline rose 2 cents to $1.64 per gallon. Heating oil climbed 4 cents to $1.96 per gallon. Natural gas fell 1 cent to $2.21 per 1,000 cubic feet.

Silver fell 6 cents to $17.46 per ounce and copper rose 1 cent to $2.62 per pound.

The dollar rose to 108.52 Japanese yen from 107.91 yen on Thursday. The euro strengthened to $1.1041 from $1.1006.

Get News Alerts delivered directly to you.

* I understand and agree that registration on or use of this site constitutes agreement to its user agreement and privacy policy.