Banks and other financial companies led another broad surge in U.S. stocks Wednesday, turning the Dow Jones industrial average and the Standard & Poor's 500 index slightly positive for the year.
It was the second rally in two days for the stock market, which had been rattled since Friday by investor concerns over Britain's vote to leave the European Union.
Those worries eased Wednesday as traders shifted money back into stocks. The gains over Tuesday and Wednesday erased more than half of the losses U.S. markets suffered in the two-day slide that kicked off on Friday.
Britain's stock market has recouped all its losses in the same stretch, but other major markets in Europe and Asia have yet to bounce back fully. Markets in France, Germany, Japan and Hong Kong have gotten back about half the ground they lost; Brazil's has recouped about three-quarters.
"The market has moved from a shock," said Erik Davidson, chief investment officer for Wells Fargo Private Bank. "The worries around 'Brexit' are now moving from short-term worries to long-term worries, and that's why we're seeing this dramatic rebound in the market."
The Dow gained 284.96 points, or 1.6 percent, to 17,694.68. The S&P 500 index rose 34.68 points, or 1.7 percent, to 2,070. The Nasdaq composite added 87.38 points, or 1.9 percent, to 4,779.25.
European stock indexes posted gains that eclipsed Wall Street's for the second day in a row. The British pound edged up against the dollar following its plunge to 31-year lows after the British vote last week.
Britain's benchmark stock index, the FTSE 100, gained 3.6 percent, while Germany's DAX rose 1.7 percent. France's CAC 40 added 2.6 percent.
On Wall Street, financial companies, which had taken the brunt of the selling after the British "leave" vote, rose 2.3 percent. The sector is still down 5.6 percent for the year. Several oil and gas production and transportation companies also notched gains as the price of crude oil rose sharply.
Global financial markets were rattled last Friday by the British "leave" vote, which many investors did not seem to anticipate. Stocks and oil fell, as did the pound, while bonds and gold rose thanks to their perceived status as safe havens. Ratings agency S&P slashed its top-shelf credit rating for the U.K.
But the two-day slump broke on Tuesday, as investors appeared to set aside their anxiety over Britain's vote.
The market also got a boost from new data on consumer spending and the latest batch of company deal news.
The Commerce Department said that consumer spending increased 0.4 percent in May on top of a 1.1 percent surge in April. The data underscore that consumer spending, which accounts for about 70 percent of U.S. economic activity, picked up in the spring after getting off to a slow start in 2016.
In currency markets, the British pound recovered some of its losses this week but remained near its 31-year low. It rose to $1.3431 from $1.3343 on Tuesday.