In a day of wild swings, Wall Street on Tuesday pared back its losses from a historic sell-off, closing up sharply despite a gloomy Federal Reserve statement that briefly sent stocks into the red.

A last-minute rally pushed the blue-chip Dow Jones industrial average past the 11,000 mark to an end-of-day gain of 4 percent. The Standard & Poor’s 500, a broader measure of the market, surged 4.8 percent while the Nasdaq, a more tech-heavy index, posted the largest gain, 5.3 percent.

The gains showed at least some investors were ready to go shopping again after Monday’s sell-off, which wiped out more than $1.2 trillion of value from U.S. stock markets. Financial stocks edged higher, after being sold down Monday, and tech stocks also moved up, with Apple briefly surpassing Exxon Mobil as the world’s most valuable corporation.

And, although investors continued to flock to safe havens such as gold, Treasurys, the Japanese yen and Swiss franc, they pulled away from safe bets toward the end of the day and sent the stock market soaring.

“We got into the last hour and it just went bananas,” said Michael Skordeles, chief market strategist at the brokerage Morgan Keegan in Memphis.

Much of the last-minute buying was not “new money” coming into the market, said Matthew Zeman, market strategist at the brokerage Kingsview Financial in Chicago. “Short” investors were probably out in full force buying shares at lower prices, he said. Those are investors who borrow shares hoping they will fall in value so they can return the securities to their owners at a lower price and pocket the difference.

“The question is: Is this genuine buying or short covering?” he asked. If it turns out to be the latter, then the markets’ gains could be short-lived, he said.

At least for a day, though, stocks bucked Monday’s global sell-off, which had continued in Asia but lost ground in Europe, where stocks mostly edged higher.

Things could have been different if U.S. stocks had not recovered from a sharp drop after the Federal Reserve’s policymaking statement that said the Fed would keep interest rates near zero through mid-2013.

Analysts interpreted the Fed’s unusually specific time horizon for its policymaking decision as a negative signal for the economy.

“Basically, the Fed said that we are going to be in an extended period of low growth and ‘we’re on hold for a couple of years, so do what you have to do,’ ” said Rich Gordon, fixed income strategist at Wells Fargo Securities in Charlotte.

“So people did what they had to do,” he said.

Traders also dumped oil, knocking $3 off the price shortly after the Fed’s decision, and sent crude futures down to their first close below $80 per barrel since October 2010. Weaker economic prospects generally send oil futures lower, though a downward revision of oil demand from the Organization of Petroleum Exporting Countries, the oil trading cartel, also contributed to the day’s slide.

Investors hoarded gold, which soared $30 to a record close of $1,740 per Troy ounce, and safe-bet foreign currencies such as the yen and Swiss franc. Immediately after the Fed’s statement, the yen gained 0.8 percent against the dollar to 77.1 yen per dollar. The Swiss franc surged an even-higher 5.3 percent to 0.71 francs per dollar, although both currencies retreated somewhat in late trading Tuesday.

The flight to safety also sent the yield on the 10-year Treasury down to 2.25 percent, yet another low for the year and down more than 1 percent since January. A lower yield means investors are willing to trade off a smaller return in exchange for the safety of holding U.S. government debt.

The scale of the yield’s decrease caught the market by surprise. But, in an age where the United States government no longer carries an undisputed top-notch credit rating, it was also oddly comforting to see the 10-year yield fall as much as it did.

“It acted like a safe haven. It acted like it always has,” Wells Fargo’s Gordon said.