Stocks posted solid gains on Monday, sending the Nasdaq composite index above 8,000 for the first time, after the White House said it has reached a preliminary agreement with Mexico on replacing the NAFTA trade deal.

The deal is far from final and the U.S. still needs to reach an understanding with Canada, the third party in the accord and the second-largest trading partner of the U.S.

Automakers, which would stand to benefit from warmer trade relations between the U.S. and Mexico, rose sharply. Banks, technology and industrial companies also made big gains.

KEEPING SCORE: The S&P 500 index climbed 22 points, or 0.8 percent, to 2,897 at closing time. The Dow Jones Industrial Average jumped 259 points, or 1 percent, to 26,049. The Nasdaq composite gained 72 points, or 0.9 percent, to 8,018. The Russell 2000 index of smaller-company stocks added 3 points, or 0.2 percent, to 1,728.

The benchmark S&P 500 has risen for seven of the last eight weeks following strong corporate earnings and growing optimism the U.S. would work out its differences with several major trading partners. The S&P 500 is up 6.5 percent since the end of June and closed at an all-time high Friday. The Nasdaq and Russell 2000 also set new highs.

TRADE TALKS: Automakers rose sharply as investors hoped that the progress in trade talks between the U.S. and Mexico would alleviate the threat of tariffs on cars and car parts. GM gained 4.7 percent to $37.63 and Ford rose 2.8 percent to $9.96.

LEADERS: While few details of the tentative trade talks have been disclosed, investors were encouraged that the countries are working toward a resolution and avoiding big disruptions in global trade, as that could have impaired their economic growth.

Exporters including industrial and basic materials makers rallied. Construction equipment maker Caterpillar rose 2.6 percent to 141.77 and chemicals maker DowDuPont gained 2.3 percent to $70.78.

Other companies that stand to benefit from faster economic growth also rose. Among banks, Goldman Sachs jumped 3.2 percent to $242.64.

In technology, Alphabet, Google’s parent company, rose 1.5 percent to $1,255.22. Amazon added 0.8 percent to $1,921.44.

THE QUOTE: Craig Birk, chief investment officer at Personal Capital, said investors were glad to get some good news on trade even though talks on a NAFTA replacement will likely continue beyond the Congressional elections this fall and into 2019.

“Most of this year has been a series of potentially negative events on trade, setting up barriers to trade, and so the market is welcoming anything that’s the opposite,” he said.

DOLLAR CHANGE: Rising trade tensions are one reason the dollar has been climbing this year, and word that a revision of the NAFTA deal could be coming sent the dollar lower on Monday. It fell to 1.2965 Canadian dollars from 1.3029 late Friday and to 18.7338 Mexican pesos from 18.9249.

TESLA’S LATEST TWIST: Tesla fell 1.8 percent to $316.86 after CEO and top shareholder Elon Musk said over the weekend that the electric car maker will remain a publicly traded company. Musk wrote in a Friday blog post that he gave up on a plan to take the company private, partly because investors didn’t support it.

Wall Street was stunned early this month when Musk tweeted that he had secured funding to take Tesla private, and while its stock jumped initially, investors remained skeptical. Musk said his proposal valued Tesla at $420 a share and the stock peaked at about $380 a share, close to an all-time high for Tesla but still well below the price he named.

Since then the stock has tumbled as it became clear Musk hadn’t lined up funding for the deal. Now reports say regulators are looking into Musk’s tweets, including whether he described the potential deal accurately, among other issues for Tesla.

BONDS: Bond prices slipped. The yield on the 10-year Treasury note rose to 2.85 percent from 2.82 percent. The increase in interest rates helped banks, but it hurt utilities and other high-dividend companies. Investors consider those big dividend payers an alternative to bonds, so they often sell them when yields start to rise.

ENERGY: Benchmark U.S. crude edged up 0.2 percent to $68.87 a barrel in the New York. Brent crude, which is used to price international oils, gained 0.5 percent to $76.21 a barrel in London.

Wholesale gasoline rose 0.6 percent to $2.09 a gallon. Heating oil added 0.6 percent to $2.21 a gallon. Natural gas fell 1.4 percent to $2.88 per 1,000 cubic feet.

METALS: Gold rose 0.2 percent to $1,216 an ounce. Silver added 0.4 percent to $14.86 an ounce. Copper picked up 0.3 percent to $2.71.

OVERSEAS: European stocks rose after a major economic survey in Germany, the Ifo institute index, came in stronger than analysts expected. Germany’s DAX rose 1.2 percent while the CAC 40 in France was 0.9 percent higher. British markets were closed for a summer bank holiday.

Japan’s benchmark Nikkei 225 index added 0.9 percent and South Korea’s Kospi rose 0.3 percent. Hong Kong’s Hang Seng jumped 2.2 percent.

© The Associated Press. All rights reserved.