The Dow Jones industrial average and S&P 500 posted their best day since March 11. Tech jumped 2 percent and financials and health care rose about 1.5 percent each to lead all S&P sectors higher.
The Dow closed off session highs but still about 213 points higher, with 3M, UnitedHealth, Visa and Goldman Sachs the top contributors to gains as nearly all constituents rose.
"The market is somewhat being driven by momentum as we get closer to the upper end of the trading range here," said Peter Cardillo, chief market economist at First Standard Financial.
The Nasdaq composite outperformed, closing 2 percent higher for its best day since March 1 and above its 50-day and 200-day moving average. Apple closed up 1.5 percent, while the VanEck Vectors Semiconductors ETF (SMH) closed 2.4 percent higher and the iShares Nasdaq Biotechnology ETF (IBB) closed up nearly 2.3 percent.
The Russell 2000 climbed more than 2 percent to close above its 200-day moving average for the first time since May 10.
Read MoreThis market getting comfortable with June hike
"I just think we came into a positive tone, which was European equities doing better," said Art Hogan, chief market strategist at Wunderlich Securities.
He attributed gains in Europe to euro weakness against the U.S. dollar, general improvement in European data, and a poll showing less support for the U.K. leaving the European Union.
A poll from ORB published in Tuesday's edition of the Telegraph newspaper showed that, among those who definitely plan to vote, support for Britain remaining in the European Union stood at 55 percent, while that for Brexit was at 42 percent.
Pound sterling traded near $1.463, around its highest since May 19.
The U.S. dollar index was up more than a third of a percent, near highs not seen since late March, with the euro around $1.114 after hitting its lowest against the dollar since mid-March. The yen was near 110 yen against the greenback.
The major European indexes closed more than 2 percent higher, with the German DAX posting its best day in five weeks. The Euro STOXX Banks Index rose nearly 3.5 percent for its best day since April 13.
"I think perhaps the market's rallying a little bit on a pullback of the likelihood of 'Brexit,'" said Jack Ablin, chief investment officer at BMO Private Bank.
Read MoreSam Zell: I'm a seller, but buying THIS
In other regional economic news, a survey by think tank ZEW showed the mood among analysts and investors worsened unexpectedly in May, with its German economic sentiment index falling to 6.4 points, Reuters reported. The think tank cited uncertainties around Britain's possible departure from the European Union and doubts the economy would continue hold the first quarter's momentum.
Meanwhile, Germany's DIHK Chambers of Industry and Commerce raised its 2016 growth forecast for the German economy to 1.5 percent from a previous estimate of 1.3 percent, supported by construction and consumption. The DIHK said Germany was getting little impetus from foreign demand and that the economy would grow at a slower pace in coming months, Reuters reported.
Ahead of weekly inventory data due late Tuesday and Wednesday morning, U.S. crude oil futures settled up 54 cents at $48.62 a barrel, its highest since October.
Brent ended half a percent higher at $48.61 a barrel, marking the first settle below WTI since January.
The Treasury Department on Tuesday sold $26 billion in two-year notes at a high yield of 0.92 percent. The 2-year yield briefly turned lower after the auction before holding higher around 0.91 percent. Earlier, the yield hit 0.93 percent, its highest since mid-March.
The 10-year yield traded off session highs around 1.86 percent.
Read MoreStrong Treasury auction could be signaling something darker on horizon
Late Monday, Philadelphia Fed President Patrick Harker said the Fed will likely raise interest rates two or three times this year. Harker is an alternate member of the FOMC this year.
Katie Stockton, chief technical strategist at BTIG, attributed the gains in S&P futures to an oversold bounce in European markets.
"We think U.S. equities will have an upward bias this week, supported by short-term positive divergences, but we expect resistance at the April highs to remain largely intact," she said in a morning note.
In other earnings news, Best Buy reported earnings that beat on both the top and bottom line but gave current-quarter forecast below Street forecasts. Separately, Best Buy CFO Sharon McCollam is stepping down June 14, and will be replaced by Chief Strategic Growth Officer Corie Barry. Shares closed 7.4 percent lower.
Read More Top-ranked analyst: Don't buy the Best Buy dip
AutoZone posted earnings that missed expectations and revenue below estimates, primarily due to weather-related factors in certain areas of the country and a legal charge, the autoparts retailer said in a release. Shares gained nearly 2.5 percent.