Bank stocks have jumped on hopes that bigger profits are ahead and US indexes again pushed to record highs.
Stocks had been mostly lower when the day's trading began, but indexes reversed course after Federal Reserve chairwoman Janet Yellen told a senate committee that the central bank could raise interest rates as soon as next month.
Bond yields jumped immediately afterwards and fed through to shares of banks, which can benefit from higher rates by charging more for loans.
The Standard & Poor's 500 index rose 9.33 points, or 0.4%, to 2,337.58 for its sixth straight day of gains. Earlier in the day, it was down as much as 0.3%.
The Dow Jones industrial average rose 92.25 points, or 0.5%, to 20,504.41.
The Nasdaq composite rose 18.62, or 0.3%, to 5,782.57. Slightly more stocks rose on the New York Stock Exchange than fell.
Ms Yellen's testimony on Capitol Hill was much anticipated, but she said little to alter most investors' expectations.
The Fed raised interest rates in December for just the second time in a decade, and Ms Yellen said the strengthening job market and a modest move higher in inflation should warrant continued, gradual increases in interest rates.
Waiting too long to raise rates "would be unwise" and could eventually force the Fed to raise rates rapidly to catch up, Ms Yellen said.
But she also repeated the word "gradual" to describe expectations for future increases.
"Yellen seemed to have her dancing shoes on this morning and was able to steer clear of any comments that might upset the market," said Alan Gayle, senior investment strategist and director of asset allocation at RidgeWorth Investments.
"In so doing, the stock market has been able to hold on to its gains."
Stocks have been on a strong run driven by expectations for more help for businesses from Washington, an improving economy and stronger-than-expected corporate earnings.
The S&P 500 is up 9.3% since Election Day.
A demonstration of how much optimism is feeding into markets is that small-business owners say they have not felt this encouraged in 12 years, according to a monthly survey released by the National Federation of Independent Business on Tuesday.
Optimism made a sharp turn higher following the election, and more small businesses are saying they are planning to hire.
Of course, such a high degree of excitement also leaves the possibility for disappointment if expectations are not met.
"The underlying momentum in the economy remains positive, so that gives us a positive bias toward the equity market, but we also know that there is a lot of volatility just around the corner," Mr Gayle said.
Ms Yellen's testimony helped the yield on the 10-year Treasury note rise to 2.47% from 2.43% late on Monday. The yield on the two-year Treasury rose to 1.24% from 1.21%, and the 30-year Treasury yield climbed to 3.06% from 3.03%.
While higher bond yields can help banks, they can also mean less demand for stocks that pay big dividends. Utility stocks in the S&P 500, which are some of the market's highest yielders, fell 0.7%. It was the largest loss among the 11 sectors that make up the index. Property investment trusts, which have relatively big dividend yields, were also weak.
General Motors jumped 1.72 dollars, or 4.8%, to 37.24 dollars for one of the biggest gains in the S&P 500 following news that France's PSA Group, maker of Peugeot and Citroen cars, is exploring a deal to buy Opel, GM's money-losing European business.
Cynosure, which makes devices used in laser body contouring, hair removal and skin care, soared after agreeing to be bought by medical device maker Hologic. Hologic will pay 66 dollars a share, or 1.57 billion dollars, for Cynosure, which had about 434 million dollars in revenue last year. Cynosure rose 14.43 dollars, or 28%, to 65.93 dollars while Hologic fell 99 cents, or 2.5%, to 39.03 dollars.
Stocks were relatively steady across the world. In Europe, the German DAX index was virtually flat, while the French CAC 40 rose 0.2% and the British FTSE 100 edged down 0.1%.
In Asia, the Hang Seng index in Hong Kong was close to flat, while the South Korean Kospi index dipped 0.2% and the Japanese Nikkei 225 index fell 1.1%.
Benchmark US crude oil rose 27 cents to settle at 53.20 dollars per barrel. Brent crude, the international standard, rose 38 cents to 55.97 dollars a gallon in London.
Natural gas fell four cents to 2.91 dollars per 1,000 cubic feet, heating oil rose a penny to 1.64 dollars per gallon and wholesale gasoline was close to flat at 1.55 dollars a gallon.
Gold fell 40 cents to settle at 1,225.40 dollars per ounce, silver rose seven cents to 17.89 dollars an ounce and copper fell five cents to 2.74 dollars a pound.
The dollar rose to 114.22 Japanese yen from 113.62 late on Monday. The euro dipped to 1.0572 dollars from 1.0600 dollars, and the British pound fell to 1.2465 dollars from 1.2529 dollars.