Stocks rose on Monday, extending last week's big gains, after the U.S. reached an agreement with Mexico on tariffs, easing some of the trade concerns which have weighed on the market since early May.

The Dow Jones Industrial Average rose for a sixth straight session, finishing the day 78.74 points, or 0.3%, higher at 26,062.68. gained about 0.5% at 2,886.73 and is now a little more than 2% from its intraday all-time high hit on May 1. The Nasdaq Composite rose 1.1% to 7,823.17 on Monday, led by Amazon.

Stocks closed off their highs of the day. The Dow was up 226.67 points at its high.

President Donald Trump announced Friday that proposed tariffs on Mexican imports would be suspended indefinitely. Trump said in a Twitter post that he has "full confidence" that Mexico will crack down on migration from Central America, after the two neighbors reached a consensus.

Shares of GM and Ford, two companies that had a lot to lose in a trade battle with Mexico because of their production there, jumped 1.5% and 0.6% respectively on Monday.

"The avoidance of Mexican tariffs is a positive but this wasn't entirely unexpected and it doesn't by any means erase the enormous risks inherent in Trump's trade policies," Adam Crisafulli, a J.P. Morgan managing director, said in a note on Monday.

Meanwhile, investors are closely monitoring the development in the U.S.-China trade war. Trump told CNBC's Joe Kernen on Monday that he believes China will make a deal with the U.S. "because they're going to have to."

"Right now, China is getting absolutely decimated by companies that are leaving China, going to other countries, including our own, because they don't want to pay the tariffs," Trump said.

Trump and Chinese leader Xi Jinping are set to meet at the G-20 Summit later this month after both countries slapped tariffs and made tit-for-tat threats. Trump said Monday if Xi skips the meeting, more China tariffs will go into effect immediately. Trump had threatened to impose duties on another $300 billion in Chinese goods if they can't strike a deal soon.

"You have to be impressed by how resilient the U.S. stock market continues to be in the face of all the uncertainties," said Jim Solloway, chief market strategist at SEI Investments. "It just shows the underlying forces that affect stock prices remains resilient and healthy. The market is reacting to the underlying strength of the economy and resilience, and I don't see that suddenly crumpling even in the face of additional Chinese tariffs."

Stocks were sent to a downward spiral by a Trump tweet on May 5 threatening to impose tariffs on Chinese imports. The Dow posted a six-week losing streak, while the S&P 500 suffered its worst month since December in May amid the escalated trade war. Now the market has made back most of the losses with the Dow about 3% from its all-time high.

The White House acting budget chief is reportedly seeking to delay the restrictions on Chinese telecom giant Huawei, which would halt its ability to purchase U.S.-made chips. Chipmakers Nvidia and Advanced Micro Devices gained 2% and 2.5% respectively on Monday following the news.