NEW YORK (Reuters) - Global stocks extended their rally into a fourth consecutive day on Wednesday after U.S. President Donald Trump and the European Union reached an agreement that investors hope will avert a trade war.

Slideshow ( 2 images )

Trump and the European Commission’s chief, Jean Claude-Juncker, agreed to work to lower industrial tariffs on both sides and to increase European imports of liquefied natural gas and soybeans from the United States, among other measures, the U.S. president said in a news conference.

The Dow Jones Industrial Average .DJI rose 172.16 points, or 0.68 percent, to 25,414.1, the S&P 500 .SPX gained 25.67 points, or 0.91 percent, to 2,846.07 and the Nasdaq Composite .IXIC added 91.47 points, or 1.17 percent, to 7,932.24.

MSCI's gauge of stocks across the globe .MIWD00000PUS gained 0.53 percent after earlier flirting with losses.

“Trade war type headlines have been the biggest driver of market sentiment - both for Treasuries and stocks - for quite a while now. This is the first time we’ve gotten good news,” said Thomas Simons, money market economist at Jefferies & Co.

Trade has been a significant barrier to the markets, but the respite may not last long.

Markets are also focused on the busiest earnings reporting week of the quarter for S&P 500 companies and also awaiting a European Central Bank meeting and U.S. gross domestic product figures later this week.

Facebook Inc FB.O shares were more than 7 percent lower after they reported results that fell short of analysts' monthly active user estimates.

Yet of the 148 S&P 500 companies that reported quarterly earnings so far, 86 percent have topped Wall Street forecasts, a record dating back to 1994, according to Thomson Reuters I/B/E/S.

The dollar index, which measures the greenback against a basket of six currencies .DXY, fell 0.4 percent, further scaling down from its July 19 peak for 2018, when Trump suggested the greenback had grown too strong.

Gold, which is priced in dollars and typically rises when the currency falls, added 0.6 percent to $1,231.71 an ounce on the spot market. XAU=

An early reprieve for 10-year Treasury notes, a benchmark for global borrowing costs, faded with the trade news.

Bond traders have been whipsawed this month by speculation the Bank of Japan could withdraw stimulus and by bets that the gap between short and long-term yields would widen if Trump pressured the Federal Reserve to stop dollar-boosting rate hikes. The latter wager - on a “steeper” yield curve - unwound for a second straight day.

The 10-year notes fell 4/32 in price to yield 2.9653 percent, and the gap between 2 and 10-year yields shrank to 29 basis points, from highs above 33 basis points on Tuesday.

Oil prices rose for a second day after U.S. crude inventories fell to the lowest in over three years, soothing worries about oversupply.

U.S. crude futures CLcv1 settled up 1.14 percent at $69.30 per barrel, while Brent LCOcv1 climbed 0.67 percent to $73.93.