"It was expected of her to be a little hawkish," said Adam Sarhan, CEO of 50 Park Investments. "From her perspective, the stock market is at all-time highs and the economic data is improving, so it's very prudent for her to be hawkish."

Fed Chair Janet Yellen said in prepared remarks that waiting too long to raise interest rates would be "unwise," given the rise in inflation and economic growth .

The Dow Jones industrial average rose about 90 points, with Goldman Sachs contributing the most gains. The S&P 500 gained 0.4 percent, with financials outperforming, notching its 15th record close since Nov. 8. The Nasdaq composite advanced 0.3 percent, as Apple reached an all-time intraday high.

"The markets were anxiously awaiting Chair Yellen's comments, but not expecting anything out of the ordinary," said Myles Clouston, senior director at Nasdaq Advisory Services. "There's also some momentum chasing the market higher; we are at all-time highs."

U.S. equities closed higher Tuesday, posting new record highs, as investors digested testimony from the top Federal Reserve official.

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

U.S. Treasury yields ticked higher following Yellen's remarks, with the benchmark 10-year note yields trading around 2.4725 percent and the short-term two-year note yield advancing to 1.2383 percent.

"The probability of a rate hike [in March] are now higher. I think interest rates are reflecting that," said Lisa Hornby, fixed income portfolio manager at Schroders. "The probability of two rate hikes is pretty good. The rest depends on how the dollar evolves."

The dollar erased earlier losses against a basket of currencies, with the euro near $1.058 and the around 114.23.

"Janet Yellen ... paved the way for three rate hikes this year," said Scott Clemons, chief investment strategist at Brown Brothers Harriman. "She is sending a message that they are on their way toward normalization."

Market expectations for a rate hike next month rose to 23 percent from 16 percent following Yellen's remarks, according to Jefferies.

Tuesday also marked the first time Yellen testifies following President Donald Trump's election.

Economic data have broadly improved since Nov. 8, with sentiment and inflation metrics all ticking higher. The NFIB small business index, which measures small-business confidence, hit 105.9, the best read since December 2004.

Stocks in the U.S. have rallied sharply since Trump's election on hopes of lower corporate taxes, fiscal spending and deregulation. On Monday, the three large-cap indexes, along with the small-caps Russell 2000, hit record highs.

"I think there are still a lot of doubters on the market," said Eric Marshall, portfolio manager at Hodges Capital. "Whenever you have that scenario, it's a lot harder for the market to pull back."

Trump hinted last week that the administration will be releasing a "phenomenal" tax plan in the next two or three weeks.

"The Fed has talked about three rate hikes for this year, but if they see fiscal stimulus coming down the hill, they might be forced to raise in March," said David Kelly, chief global strategist at JPMorgan Funds. "There's a big wait-and-see attitude in terms of, do you pay for what the president promised through spending cuts or do you let the deficit grow."

"I think there should be some nervousness in the market about that," he said.