Strong housing data, rising oil prices and increasing confidence that higher interest rates won't undermine stock prices combined to help lift major indexes as investors sold government bonds and gold. All 10 S&P 500 sectors rose.
The Dow Jones Industrial Average rose 209 points, or 1.2%, to 17702, while the S&P 500 climbed 1.3%.
Some investors said stocks were still absorbing recent indications that the U.S. Federal Reserve may raise interest rates in coming months. Rising rates are good for banks because they increase the gap between what banks charge on loans and what they pay for deposits, a spread known as the net interest margin.
Philadelphia Fed President Patrick Harker said Monday he could "easily" see the U.S. central bank raising rates two to three times this year, possibly as soon as June.
"I think the markets are coming to grips with the fact that the Fed is going to raise interest rates, the world's not going to end, and let's see who benefits," said Bob Doll, senior portfolio manager at Nuveen Asset Management. "Financials are among those who should benefit."
Financial stocks in the S&P 500 gained 1.5%, while the KBW Nasdaq Bank Index of large U.S. commercial lenders rose 1.7%. Morgan Stanley climbed 2.7%, and Citigroup rose 2.1%.
The tech-heavy Nasdaq Composite added 1.7%, while technology shares in the S&P 500 gained 1.9%. Western Digital rose 4% and Lam Research added 3.4%.
Sales of new homes rose at the fastest pace in more than eight years in April as prices rose, a sign of steady demand and limited supply. Purchases of new single-family homes jumped 16.6% from a month earlier to a seasonally adjusted annual rate of 619,000, the Commerce Department said Tuesday. That is the fastest pace since January 2008.
Shares of Toll Brothers, a luxury home builder, rose 5.2% as it reported better-than-expected profit and revenue in its second quarter. "We continue to believe the drivers are in place to sustain the current housing market's slow but steady growth," said Robert I. Toll, executive chairman.
Best Buy issued a soft profit forecast for the current quarter, helping drive shares down 7.1%.
U.S. government bonds pulled back, sending the two-year yield to the highest level in more than two months, amid investor concerns about a rate rise this summer. The yield on the two-year note, which is highly sensitive to the Fed's rate-policy outlook, was 0.926%, the highest intraday level since mid-March. It was 0.899% on Monday.
The yield on the benchmark 10-year Treasury note was 1.877%, according to Tradeweb, compared with 1.840% Monday.
"Some of the economic news that's come out has been fairly nice," said Tom Carter, managing director at brokerage JonesTrading. "There's the underpinnings of something to build on."
U.S. crude oil added 1.2% to $48.65 a barrel. Gold fell 1.8% to $1,229.30 an ounce.
In Europe, the Stoxx Europe 600 reversed early losses to rise 2.2%.
Eurozone finance ministers were meeting Tuesday to discuss options for Greek debt relief, after the country's parliament approved taxes and austerity measures over the weekend needed to unlock further rescue loans.
"For once, there's good news on Greece," said Mike Bell, global market strategist at J.P. Morgan Asset Management, noting investor sentiment was lifted by hopes that Greece will receive relief before major debts fall due in July.
In currencies, the euro slipped 0.5% against the dollar to $1.1158. German economic growth accelerated at the start of the year, data showed Tuesday, but a separate report from German think tank ZEW showed financial analysts grew more pessimistic about the country's economic outlook.
The dollar rose 0.6% against the yen to Yen109.933. Japan's finance minister said Tuesday that the country has no plans to weaken the yen to try to boost exports, following weeks of market speculation.
The British pound rose 1% against the dollar to $1.4630 after an opinion poll pointed to a lower chance of the U.K. voting to leave the European Union in a June 23 referendum.
"The pound has had a little jump for joy on fact that Brexit risk is reducing, but sterling could fall quite a bit more if Britain left [the EU]," Mr. Bell said.
Shares in Asia mostly ended lower as investors continued to grapple with the prospect of higher U.S. interest rates.
Japan's Nikkei Stock Average fell 0.9%, while the Shanghai Composite Index fell 0.8%. Hong Kong's Hang Seng Index added 0.1%.
Min Zeng and Ian Talley contributed to this article
By Aaron Kuriloff and Riva Gold