The S&P 500 climbed 1.4 percent, with financials rising 2.8 percent to lead advancers, and briefly broke above 2,400 for the first time. The index closed above 2,300 for the first time on Feb. 9.

The Dow advanced about 300 points with Goldman Sachs contributing the most gains and closing above 21,000 for the first time. The 30-stock index first closed above 20,000 on Jan. 25.

"The major positive from the speech is he delivered on his 'America first' message, but he did so in a positive and uniting way," said Zhiwei Ren, portfolio manager at Penn Mutual Asset Management. "If his message of 'America first' can succeed, this could be positive for the economy" in the near term.

Trump's speech, which was delivered Tuesday night, was widely praised for its positive tone but lacked specifics about tax reform and deregulation, two key components of the market's postelection rally.

"That's why I'm a little wary," he said.

"A lot of people say this is euphoria. But it doesn't feel like it," said Eddie Perkin, chief equity investment officer at Eaton Vance. "It feels like people are reluctantly buying stocks."

U.S. equities surged to all-time highs Wednesday, the major indexes posting their best day of the year, on the back of President Donald Trump's speech to Congress.

Traders work on the floor of the New York Stock Exchange.

Quincy Krosby, market strategist at Prudential Financial, said the speech's tone "has gone a long way for the market" as it "assuaged fears that his agenda was not going to be able to be passed."

Dow futures soared more than 150 points ahead of the open, while S&P and Nasdaq futures advanced 18 and 34 points, respectively.

"While it's understandable that these things take time to plan and implement properly, markets have been way ahead of the game since Trump's victory and there comes a time when we need to know exactly what they're rallying on," said Craig Erlam, senior market analyst at Oanda, in a note.

Equities had closed lower on Tuesday, with the Dow snapping a 12-day winning streak.

Investors also paid close attention to key economic data, as the probability of the Federal Reserve raising rates surged.

Personal income rose 0.4 percent in January, topping expectations, while consumer spending slowed. However, the personal consumption expenditures (PCE) price index jumped 1.9 percent in the 12 months through January, putting inflation very close to the Federal Reserve's target of 2 percent.

Construction spending fell 1 percent in January, well below expectations, but the February ISM manufacturing index rose to 57.7, expanding on January's 56.0 reading.

The Fed's Beige Book was also released Wednesday, and it showed that U.S. businesses remained generally optimistic but less so than in the previous report.

Market expectations for a rate hike this month almost doubled Wednesday to around 70 percent, according to the CME Group's FedWatch tool.

Also lifting March rate hike expectations were remarks from New York Fed President William Dudley, who told CNN International on Tuesday that he sees a rate hike in the "relatively near future," adding that the case for tighter monetary policy has become more compelling.

"I disagree with those who think the Fed doesn't matter anymore in terms of their influence in the context of a debt to GDP ratio that has never been higher and market valuations that are historically very rich," said Peter Boockvar, chief market analyst at The Lindsey Group.

"Changes in fiscal policy are welcome for the economy but I lean towards monetary policy in being more impactful on markets in the shorter term time horizon," he said.

U.S. Treasury yields rose broadly, with the two-year note yield hitting its highest level since 2009 and the benchmark 10-year note yield jumping to 2.46 percent.

In corporate news, investors awaited social media firm Snap Inc. to price at the New York Exchange Wednesday night before its Thursday IPO.

"It's a very well-known name and it's probably the most interesting IPO since Facebook," said Tom Wright, director of equities at JMP Securities. "I think market participants are going to look at where it prices and how it trades."

"It will give us a window into the tech IPO market, which has been subdued," he said.

Snap was set to price its initial public offering at $17 a share, sources told CNBC.