New York (CNN Business) US stocks recorded their second best day of the year on Tuesday, rallying as hopes for a Federal Reserve rate cut took hold and worries about an escalating trade war took a backseat.

Thefinished the day up 512 points, or 2.1% — its best day since January 4. The Nasdaq closed 2.7% higher, erasing its losses after a steep selloff on Monday that was driven by worries about tech regulation.

The, meanwhile, ended up 2.1%. Both the Nasdaq and the S&P recorded their best days since January 4.

Just last week, this picture looked substantially different. The trade war has put pressure on equities. Proposed tariffs on Mexican imports to the United States are set to go into effect Monday

But investors brushed aside those fears. US markets opened higher, and those gains accelerated after Federal Reserve Chairman Jerome Powell said that the central bank was closely monitoring developments on the trade front

"As always, we will act as appropriate to sustain the expansion," he said Tuesday at a monetary policy conference in Chicago.

Powell's remarks came a day after St. Louis Fed President James Bullard said the central bank may need to cut interest rates soon amid concerns about weak inflation and risks to economic growth.

Although Powell didn't echo Bullard's more explicit expectation for a rate cut, investors seems to have heard all they needed to hear.

According to the CME's FedWatch tool, market expectations for an interest rate cut at the Fed's July meeting are 65%, having moved significantly higher over the course of the day. By December, the chances are 98%.

Expectations for an interest rate cut were already growing before this week's comments by Bullard and Powell, noted MUFG chief financial economist Chris Rupkey. They climbed even more after President Donald Trump threatened Mexico with tariffs.

There are no signs of a recession anywhere in the economic data, Rupkey added, which would be a traditional reason for the Fed to lower rates.

Trump has long called on the central bank to cut rates to stimulate the economy.