At the close, the broad S&P 500 index and the Dow Jones industrial index had both risen 1.1 percent. The technology-heavy Nasdaq's composite index had risen 1.4 percent.
Both the S&P 500 and Nasdaq's composite index thus noted record-high closing levels.
In the afternoon, a slightly scattered consumer price index (CPI) was released. The inflation rate on an annual basis landed in July at 2.7 percent, unchanged from June. But the so-called core inflation, cleaned for food and energy, rose from 2.9 percent in June to 3.1 percent in July, which was higher than expected.
The CPI weighs heavily on the levels of the country's interest rate, which the central bank Federal Reserve (Fed) will next decide on at its meeting on September 17-18.
Fed's inflation target is 2 percent.
The market had on Monday priced in that Fed with 87 percent probability will cut the interest rate next month, from today's interval of 4.25-4.5 percent.
Left on the table
The new CPI figures provide ammunition to those who believe that Fed has room to cut, at the same time as they reduce some of the concern that new import tariffs will fuel a lasting price pressure.
Ellen Zentner at the financial advisory firm Morgan Stanley Wealth Management tells the news agency Bloomberg that inflation is on its way up, but not as much as some feared.
In the short term, the markets will likely take in these figures because they should make it possible for Fed to focus on the labor market's weakness and keep an interest rate cut in September on the table.
Jason Pride, investment manager at the financial advisory firm Glemede, also points to the balance between the labor market and inflation - and thinks he sees what decision Fed will land in:
The stars seem to be lining up for an interest rate cut in September.
Intel climbed
The stock market gains also come after Trump announced that the tariff pause against China will be extended by another 90 days.
On Thursday, a producer price index will also be released.
One of Tuesday's winners was the processor manufacturer Intel, with CEO Lip-Bu Tan.
This after President Donald Trump - after last week demanding the CEO's resignation - said that the two had had a "very interesting" meeting about a cooperation.
According to Intel, it was about "strengthening American leadership in technology and manufacturing".
Intel's share rose 5.6 percent.