IBT image IBMtraders
Traders work on the floor of the New York Stock Exchange. Reuters

This story was updated at 4:15 p.m. EDT.

U.S. stocks rallied strongly Monday, tracking gains in European stocks, as polls over the weekend showed an increased possibility of Britain remaining in the European Union.

The day's gains erased most of last week's decline, which came partly on worries of what a British exit from the EU would mean for the global economy and trade. The vote on whether to stay is scheduled for Thursday.

The most recent polls showed a change in momentum favoring the "remain" camp just days away from the vote.

"The market is positioning for a 'remain' vote, so you see the fear and uncertainty trade unwinding right now," said Quincy Krosby, market strategist at Prudential Financial in Newark, New Jersey.

She said, however, that the reverse trade could be triggered by any sign the Brexit -- or British exit from the EU -- camp is gaining momentum.

"It is a long time between now and Thursday."

Major U.S. stock indexes were up almost 1 percent by the close of trading. The Dow Jones Industrial Average finished with a gain of 130 points, while the S&P 500 stock index added 12 points. The Nasdaq composite, which includes many tech names, added 37 points.

Wall Street closed lower Friday, weighed down by technology stocks. The three major indexes lost more than 1 percent each in the week after the Federal Reserve warned of an economic slowdown and investors fretted over a possible Brexit.

Wells Fargo's 1 percent rise gave the S&P a boost, while the Dow was lifted the most by a 1.5 percent rise in Goldman Sachs.

Apple Inc. (AAPL) Stock Price | FindTheCompany

Earlier, shares of Apple Inc. were up sharply, rebounding from the tech giant's 2.2 percent drop Friday after a dispute in China over an iPhone patent.

The British pound gained 2.3 percent versus the U.S. dollar on its strongest day in 7-1/2 years.

U.S.-traded shares of JD.com rallied over 5 percent to $21 after Walmart said it would sell its Chinese e-commerce business to JD.com and create a strategic alliance. Walmart shares gained 0.2 percent to $71.

Lending Club Corp. gained 3 percent to $5 after Chinese billionaire Chen Tianqiao raised his stake in the online lending platform, following the recent ouster of founder and Chief Executive Renaud Laplanche.

Fed Chair Janet Yellen is scheduled to testify before the Senate Banking Committee on Tuesday at 10 a.m. ET.

Reuters contributed to this report.