The S&P 500 rose 0.1 percent and briefly broke above 2,900 for the first time ever. The Nasdaq Composite also hit a record high, climbing 0.2 percent as Apple rose more than 1 percent. The Dow Jones Industrial Average advanced 46 points.
Nicholas Colas, co-founder of DataTrek Research, said in a note the recent breakout is "a function of a baseline assumption (further corporate earnings growth and low rates) and a fresh input (a US Mexico trade deal means other trade/tariff negotiations are also likely)."
"Trade has been the biggest overhang on US stocks, so the latter point has some runway to shove large caps even higher in the near term," he said.
The U.S. and Mexico announced Monday they came to an agreement that would replace NAFTA, an accord that currently includes both countries and Canada.
Treasury Secretary Steven Mnuchin told CNBC's "Squawk Box" on Tuesday he is hopeful a deal with Canada will get done, but added he is prepared to "move forward with Mexico." Mnuchin also said: "This is a great deal for American workers. If you remember one thing, this deal is about more trade for U.S. companies and goods and services, and that's what we're focused on."
Trump has repeatedly railed against NAFTA, calling it the worst trade deal ever. On Monday, he said: "The name NAFTA has a bad connotation because the United States was hurt very badly by NAFTA."
Trade spats between the States and other major economies have put markets on a roller-coaster ride lately, even as positive economic data and earnings are released. Once the trade situation between the U.S., Canada and Mexico is resolved, the U.S. will move on to squaring trade differences with China, its biggest partner.
The S&P 500 and Nasdaq Composite closed at all-time highs on Monday. The Nasdaq also broke above 8,000 for the first time ever. Trump touted the milestone in a tweet Tuesday, saying: "NASDAQ has just gone above 8000 for the first time in history!"
"In March, we had four areas of trade uncertainty: Mexico, China, Europe and Canada. I think Canada will be resolved and Europe and Canada are already resolved," said Tom Essaye, founder of The Sevens Report. "Basically, we've got three of four resolved, but China is a big one."
Essaye also said he would be surprised if stocks keep grinding higher without a resolution to U.S.-China trade relations.
Consumer confidence rose in August to its highest level since October 2000.
Footwear retailer DSW rose more than 20 percent after reporting better-than-expected quarterly earnings. Tiffany shares also rose 0.6 percent on stronger-than-forecast earnings.
—CNBC's Kayla Tausche contributed to this report.