Stocks rallied to close near session highs Thursday, with major averages wiping out the previous session's losses, lifted by a pair of better-than-expected economic data and as investors shrugged off another steep selloff in the Japanese market.

Stocks took another leg higher in the final hour of trading after the Wall Street Journal reported that an adjustment in the Federal Reserve's bond-buying program did not mean that the central bank would end "all at once" or that the Fed was "anywhere near raising short-term interest rates."

Nagging worries about the Federal Reserve tapering its bond-buying program and disappointment over the Bank of Japan's decision pushed the market sharply lower in the last two days. Despite the session's rally, major averages are currently on pace for their worst monthly performance since October 2012.

"We had some good data and the market seems to have stopped looking at the turmoil in Japan—at least for today," said Brian Gendreau, market strategist at Cetera Financial. "But everyone's focused on the Fed now…Volatility will likely continue—the Vix is a bit higher than usual, which implies a little bit of apprehension and people getting concerned."

On the economic front, weekly jobless claims declined 12,000 to a seasonally adjusted 334,000 last week, according to the Labor Department, falling near the lowest level in nearly five years. And retail sales climbed 0.6 percent in May, according to the Commerce Department, topping expectations for a gain of 0.4 percent. Retail sales account for about 30 percent of consumer spending.

Meanwhile, business inventories rose 0.3 percent in April, according to the Commerce Department, in line with expectations. Inventories are a key component of GDP changes. And import and export prices declined unexpectedly in May.

Earlier, Japan's benchmark Nikkei plunged over 6 percent, pushing the benchmark firmly back in bear market territory for the second time in less than a week. The index has tumbled more than 20 percent from last month's 5 1/2-year high of 15,942.

Interestingly, the dollar/yen dropped below the key 95-handle to a new 10-week low, but stocks still held gains, signaling a trend reversal as equities have moved very closely with the yen for the past several weeks.

"We are seeing the first signs of a lack of confidence in the ability of central banks to control the interest rates, and to stimulate inflation and real GDP growth rates," said Viktor Shvets, head of strategy research, Asia, at Macquarie.

Will Volatility Last?

Will it be a June swoon? Dissecting the fall in Japan and an increase in volatility in the markets, with Dan McMahon, Raymond James, and Mark Otto, Knight Capital.

Coty slipped in its market debut on the New York Stock Exchange. The beauty-products maker priced its IPO at $17.50 a share.

DuPont declined after the chemical company it expects to see full-year earnings at the lower end of its previously issued guidance, citing unseasonably cool weather across the U.S. and Europe.

Safeway surged after Empire, the operator of Canadian grocery chain Sobeys, said it will acquire the supermarket chain's operations in Canada for approximately $5.7 billion. In addition, JPMorgan and Guggenheim raised their price target on Safeway.

Gannett spiked to lead the S&P 500 gainers after the newspaper chain said it will acquire television company Belo for $1.5 billion. The deal will nearly double Gannett's broadcasting holdings, making the company the fourth-largest U.S. owner of major network affiliates.

Meanwhile, a U.K. parliamentary report out on Thursday panned Google for aggressively avoiding paying corporate tax in Britain, and said its international reputation will be damaged until it pays what it owes.

Treasurys cut their gains after the government sold $13 billion in 30-year bonds at a high yield of 3.355 percent. The bid-to-cover ratio, an indicator of demand, was 2.47.