Stocks rose on Tuesday after a report said the U.S. and China are seeking talks to defuse an escalating trade conflict between the two countries. Equities also posted their biggest monthly gains since the start of the year.

The Dow Jones Industrial Average jumped 108.36 points to close at 25,415.19, with 3M, Caterpillar and Pfizer as the best-performing stocks in the index. The gained 0.5 percent to 2,816.29 as industrials rose more than 2 percent. The Nasdaq Composite advanced 0.6 percent to 7,671.79.

Bloomberg News reported that the world's largest economies are trying to restart talks in order to avoid a full-blown trade war. The report, which cites two people familiar with the situation, said Treasury Secretary Steven Mnuchin and Chinese Vice Premier Liu He are talking privately about the matter. Mnuchin told CNBC last week "there continue to be some quiet conversations" regarding China.

"It's just an agreement to have talks. We don't know where the talks go or whether they will be fruitful. They seem to be resuming high-level talks. We'll have to see what comes of it," said Peter Boockvar, chief investment officer at Bleakley Advisory Group.

Shares of big exporters Boeing and Caterpillar jumped 1.5 percent and 2.9 percent, respectively, on the report. Deere's stock also gained nearly 5 percent.

Tuesday was the last trading day of July, and the major averages posted solid monthly gains. The Dow and S&P 500 rose 4.7 percent and 3.6 percent, respectively, their biggest monthly gains since January. The Dow gained 5.8 percent in January, while the S&P 500 rose 5.6 percent that month. The Nasdaq, meanwhile, climbed more than 2 percent in July and notched its fourth straight monthly gain.

Equities have gotten a boost this month from strong corporate earnings and positive economic data.

The Commerce Department said on Friday the U.S. economy grew by 4.1 percent in the second quarter, notching its fastest growth rate since the third quarter of 2014. The economy got a boost from strong consumer and business spending as well as a surge in exports.

About 60 percent of the S&P 500 has released its latest quarterly results, with 82 percent of those companies posting better-than-expected earnings, according to Thomson Reuters I/B/E/S.

"Do you remember all the pundits who warned 1Q 2018 earnings were at their peak? Well, the 2Q 2018 numbers for these 299 S&P 500 companies that have reported are better than how they reported last quarter in terms of year-over-year sales and earnings growth. There are also more companies beating estimates this quarter as well," Nick Raich, CEO of The Earnings Scout, wrote in a note.

The corporate earnings season continued on Tuesday with Dow components Procter & Gamble and Pfizer reporting better-than-expected earnings. Shares of Procter were up 0.9 percent, while Pfizer's stock gained 3.5 percent. Apple, another Dow component, is scheduled to report Tuesday after the close.