Updated from 4:08 p.m. EDT

Stocks ended the week with solid gains Friday as traders cheered surprisingly positive data on the housing sector and the broader economy.

The

Dow Jones Industrial Average

rose 142.99 points, or 1.08%, to 13,378.87, helped by a strong upswing in the last hour of trading. The

S&P 500

added 16.87 points, or 1.15%, to 1479.37. After opening lower, the

Nasdaq Composite

jumped 34.99 points, or 1.38%, to 2576.69.

The market shrugged off early sluggishness after the Commerce Department said new-home sales unexpectedly rose 2.8% to 870,000 annualized units. Economists had expected that sales would decline 1% to 825,000 units. June's initial read of 834,000 units was revised upward to 846,000.

"These numbers tend to be volatile and are subject to revisions," pointed out Steven Sheldon, principal of SMS Capital Management. "It's hard to understand why home sales are surging right now. It will take months to unfold, so you can't take credence in one set of numbers. This is already dated information, but the

Federal Reserve

will be paying attention."

Also on the economic front, the government said durable goods orders jumped 5.9% in July, nearly six times the consensus target and triple the revised 1.9% advance in June. Excluding transportation, orders rose 3.7%, the largest climb in two years.

Both reports arrived a day after

Countrywide Financial's

( CFC) CEO Angelo Mozilo rattled the market, saying in a televised interview on

CNBC

that the credit environment is "not getting better" and that it's not clear when the housing cycle will bottom.

Mozilo added that a downturn in housing could possibly lead to a recession, and that the Fed should cut rates in order to get new liquidity into the market.

Those comments contributed to the major averages' inability to hold early gains last time out, when the Dow eased 0.25 points at 13,235.88. The S&P 500 slipped 1.57 points at 1462.50, and the Nasdaq shed 11.10 points to 2541.70.

Shortly after the last close, a report on loans made through the Fed's discount window was released, showing that an average of about $1.2 billion a day was borrowed by banks during the past week. Last week, the Fed cut the discount rate, the interest rate it charges to lend to banks, by 50 basis points to 5.75%.

Financial subsector indices started lower but finished with slight gains. The Nasdaq Financial 100 advanced 1%, the NYSE Financial Sector Index was up 0.7%, and the KBW Bank Index tacked on 0.5%.

The major averages finished higher for the week as the recent turmoil in the credit markets abated somewhat. The Dow rose 2.3% over the five sessions, the S&P 500 added 2.4%, and the Nasdaq ended up 2.8%.

Breadth was decidedly positive, while volume was weaker compared to previous sessions. On the

New York Stock Exchange

TheStreet Recommends

2.60 billion shares changed hands, as advancers topped decliners by a 2-to-1 margin. Volume on the Nasdaq reached 1.66 billion shares, with winners outpacing losers nearly 3 to 1.

Turning to stocks,

Home Depot

(HD) - Get Home Depot, Inc. (HD) Report

may accept $1.2 billion less than the original $10.3 billion from three

private-equity companies in a deal for its wholesale distribution business, according to a report in

The Wall Street Journal

. Home Depot added 66 cents, or 1.9%, to $34.68.

Marvell Technology

(MRVL) - Get Marvell Technology Group Ltd. Report

dropped 11.8% after it swung to a second-quarter loss. Marvell lost $2.10 to $15.75.

Brocade Communications

(BRCD)

rose 4.3% after topping third-quarter estimates following the previous close. Brocade was higher by 30 cents at $7.26.

Apparel retailer

Gap

(GPS) - Get Gap, Inc. (GPS) Report

posted a better-than-expected 19% rise in second-quarter profits and raised its guidance for the year. Gap ended up $1.11, or 6.4%, to $18.51.

Meanwhile, fellow clothing seller

AnnTaylor

(ANN)

said second-quarter profits dropped 27% from a year ago but still topped expectations. The stock climbed $2.79, or 9.4%, to $32.43.

Gains in Gap and AnnTaylor boosted the S&P Retail Index, which finished with a gain of 1.9%.

Elsewhere, the front-month October crude contract rose $1.26 to end at $71.09 a barrel. Gasoline prices gained 6 cents at $1.99 a gallon.

Treasury bonds were gaining ground. The 10-year note was higher by 5/32 in price, yielding 4.63%. The 30-year bond added 26/32 in price, cutting the yield to 4.89%.

Global indices were mostly lower. Overnight, Hong Kong's Hang Seng Index fell 0.2% and Japan's Nikkei 225 shed 0.4%. In Europe, London's FTSE was up 0.4%, while Germany's Xetra Dax lost 0.1%.