The S&P 500 closed at its highest in 2016 on Tuesday after Federal Reserve Chair Janet Yellen called for caution on raising interest rates - music to Wall Street's ears.
In her first comments since the Fed held steady on rates earlier this month, Yellen said global risks remained, including uncertainty over China and low oil prices.
That was enough to reverse an earlier dip in stocks and leave the S&P 500 0.88 percent higher, its biggest one-day gain in 12 sessions.
After its worst January since 2009, the S&P 500 has fully recovered and is now up 0.55 percent for 2016, although investors remain concerned about a slow global economy, a strong dollar, volatile oil prices and lackluster top-line growth at U.S. companies.
Yellen's cautious tone contrasted with recent comments from other policymakers, including the chiefs of the Philadelphia and Atlanta Federal Reserves, who had expressed support for a more aggressive approach to raising interest rates this year.
Fed funds futures implied that traders now see a 46-percent chance the Fed will raise rates by a quarter point at its July policy meeting, below the 51 percent chance seen on Monday, according to CME Group's FedWatch program.
"Given the much less dovish-than-expected commentary we got from a number of Fed speakers last week, many were looking for a shift in tone from Ms. Yellen and we didn't get that,” said Omer Esiner, chief market analyst at Commonwealth Foreign Exchange.
Economic and financial troubles in countries around the world have led policymakers to project slower path of rate hikes than initially expected in December.
The Dow Jones industrial average .DJI rose 0.56 percent to end at 17,633.11 points and the S&P 500 .SPX gained 17.96 points to 2,055.01.
The Nasdaq Composite .IXIC rallied 1.67 percent to 4,846.62.
All 10 major S&P sectors rose, led by tech stocks .SPLRCT, up 1.58 percent.
The energy index .SPNY added 0.35 percent despite a 2.5 percent drop in Brent crude oil. U.S. stocks and the price of oil have often moved in lockstep in recent months but that was not the case Tuesday.
Shares of some banks, which stand to gain from higher interest rates, were the biggest drags on the S&P 500. Bank of America (BAC.N) and Wells Fargo (WFC.N) each declined over 1 percent.
Advancing issues outnumbered decliners on the NYSE by 2,448 to 594. On the Nasdaq, 2,109 issues rose and 735 fell.
The S&P 500 index showed 50 new 52-week highs and one new low, while the Nasdaq recorded 63 new highs and 47 new lows.
About 7.0 billion shares changed hands on U.S. exchanges, below the 7.8 billion daily average for the past 20 trading days, according to Thomson Reuters data.
(Additional reporting by Yashaswini Swamynathan and Abhiram Nandakumar in Bengaluru; Editing by Nick Zieminski)