By Lewis Krauskopf

(Reuters) - Wall Street rolled to a third straight day of gains on Thursday as Britain's central bank raised the prospect of stimulus and consumer staples shares gained on news of Mondelez International's $23 billion bid for Hershey.

The major U.S. indexes each closed up more than 1 percent, tallying their best three-day run in four months. They have erased the bulk of their losses in the wake of Britain's shock vote a week ago to leave the European Union that had set off the worst two-day decline for Wall Street in 10 months.

In the wake of the referendum, Bank of England Governor Mark Carney said on Thursday that the central bank would probably need to pump more stimulus into Britain's economy over the summer.

"We’re reversing the 'Brexit' as it becomes evident that it was more of a political vote and decision than an economic decision," said Bucky Hellwig, senior vice president at BB&T Wealth Management in Birmingham, Alabama.

Stocks also might be benefiting as portfolio managers adjust their holdings at the end of the quarter, Hellwig said.

The Dow Jones industrial average <.DJI> rose 235.31 points, or 1.33 percent, to 17,929.99, the S&P 500 <.SPX> gained 28.09 points, or 1.36 percent, to 2,098.86 and the Nasdaq Composite <.IXIC> added 63.43 points, or 1.33 percent, to 4,842.67.

All ten S&P sectors ended higher, led by a 2.2 percent climb for consumer staples shares <.SPLRCS>. Hershey <HSY.N> shares surged 16.8 percent after news that Mondelez <MDLZ.O> had made a takeover offer, which Hershey rejected, looking to create the world's largest confectioner. Mondelez <MDLZ.O> gained 5.9 percent.

Investors are still bracing for volatility in coming weeks amid uncertainty about how Britain will pursue its EU exit, even as the S&P 500, which was within 17 points of its May 2015 record high a week ago, closed out its third straight positive quarter.

"I think there will still be other times when we revisit 'Brexit' fears to some extent," said Jim Paulsen, chief investment strategist at Wells Capital Management in Minneapolis. "But I don’t think it’s going to turn out to be near as big as people thought in terms of financial or economic fallout, and I’d get more prepared for breaking the new record highs."

Adding to positive U.S. economic data from earlier in the week, factory activity in the U.S. Midwest surged to its highest in almost 1-1/2 years in June amid strong gains in new orders and production, offering a ray of hope for the downtrodden manufacturing sector.

Visa <V.N> fell 3.3 percent and MasterCard <MA.N> dropped 4.4 percent after a federal appeals court threw out an antitrust settlement the credit card companies had reached with millions of retailers. The stocks were the two biggest drags on the S&P.

About 8.7 billion shares changed hands in U.S. exchanges, above the roughly 7.6 billion average over the past 20 sessions.

NYSE advancers outnumbered decliners by a 3.85-to-1 ratio; on the Nasdaq, a 2.46-to-1 ratio favored advancers.

The S&P 500 posted 90 new 52-week highs and 1 new lows; the Nasdaq recorded 86 new highs and 31 new lows.

(Assitional reporting by Yashaswini Swamynathan in Bengaluru; Editing by Nick Zieminski)