Stocks rose sharply on Thursday, helped by consumer discretionary shares after Bed Bath & Beyond Inc posted a surprising profit increase and home builder Lennar Corp reported a rise in new home sales.

Lennar posted a wider quarterly loss, but noted an increase in new sales and orders. Its stock shot up 16.5 percent to $9.11.

The Dow Jones U.S. home construction index <.DJUSHB> jumped 5.7 percent.

Gains in home builders and retailers point to signs of strength in consumer spending, which could be a boon for stocks just as the second-quarter earnings reporting period gets under way.

To us, this is a market that wants to move higher. I think the market's recovering from that 6 percent decline from recent highs, said Tim Ghriskey, chief investment officer of Solaris Asset Management in Bedford Hills, New York.

The Dow Jones industrial average <.DJI> was up 149.86 points, or 1.81 percent, at 8,449.72. The Standard & Poor's 500 Index <.SPX> was up 16.53 points, or 1.83 percent, at 917.47. The Nasdaq Composite Index <.IXIC> was up 30.93 points, or 1.73 percent, at 1,823.27.

Earlier, all three indexes gained as much as 2 percent to 2.29 percent to hit session highs.

Another sign that encouraged investors was news the Federal Reserve was extending a number of emergency funding facilities while scaling back some others.

What we saw is an improvement here in that one program went away, but also the flexibility that these other ones are staying around in case they're needed, said Bucky Hellwig, senior vice president at Morgan Asset Management, in Birmingham, Alabama.

An auction of $27 billion of 7-year notes attracted strong demand, pressuring U.S. Treasury bond yields. The auction completed this week's sales of Treasury coupons, with all three auctions seeing solid demand.

In the retail sector, Bed Bath & Beyond reported a surprising increase in quarterly profit as it cut costs to offset slumping demand, and its stock gained 10.2 percent to $31.29. The retail index <.RLX> climbed 3.8 percent.

There was also some relief in the market that Federal Reserve Chairman Ben Bernanke had weathered a tough grilling in Congress relatively well.

(Additional reporting by Leah Schnurr; Editing by Jan Paschal)