By Karen Jacobs

But the retailer said it still expects full-year profit to fall about 24 percent this year, in line with its most recent forecast.

Shares of Home Depot rose less than 1 percent in pre-market trading.

The second quarter is typically one of the strongest for home improvement retailers as consumers spruce up their houses in warmer weather. On Monday, smaller rival Lowe's Cos posted higher-than-expected quarterly results but forecast third-quarter profit that trailed Wall Street estimates.

Analysts cited better expense control and improved gross margin from Home Depot, which has taken steps to cut costs and reinvest in its older stores.

"(Chief Executive) Frank Blake has come in and refocused the firm on its core retail operations," said Walter Todd, a principal and portfolio manager with Greenwood Capital in Greenwood, South Carolina. "That initiative will take time."

Still, the crumbling U.S. housing market has compounded troubles as consumers take on fewer big-ticket renovations and face higher food and gasoline costs. The second quarter marked the eighth-straight quarterly profit decline for Home Depot.

Net earnings declined 24 percent to $1.2 billion, or 71 cents a share, in the quarter ended on August 3, from $1.59 billion, or 81 cents a share, a year earlier.

Analysts had expected earnings of 61 cents a share, according to Reuters Estimates.

Blake cited "improved execution in our merchandising and operations initiatives" during the quarter.

Sales fell 5 percent to about $21 billion, but were better than the $20.58 billion analysts expected. Sales at stores open at least a year fell 7.9 percent. The average purchase fell 1.2 percent to $57.58.

SCALING BACK STORE GROWTH

Last year, Home Depot sold its supply unit that distributed building materials and used the proceeds to buy back stock. This year, it has scaled back store growth, cut headquarters and human resource jobs and redirected savings from those moves to store maintenance and staffing.

Home Depot, which announced the closure of about 15 underperforming stores in May, is also building more rapid deployment centers to move products more quickly into stores and lower distribution costs.

The retailer "is reinvesting back into systems, labor and merchandising and that is putting additional pressure on earnings," Credit Suisse analyst Gary Balter said in a research note. But he added that Home Depot had not been able to close the sales gap with Lowe's, which said its second quarter same-store sales fell a less-than-expected 5.3 percent.

Home Depot said it expected per-share profit from continuing operations to fall about 24 percent this year, as sales decline about 5 percent.

Home Depot shares rose to $27.20 from its close on Monday of $26.96.

(Editing by Dave Zimmerman)