Dell Inc reported a stronger-than-expected quarterly profit on Thursday, showing it was better able to cut costs and protect prices on its products than analysts, or its own executives, had predicted.

Shares of the world's No. 2 personal computer maker rose 7 percent after the earnings announcement, which preceded the close of stock market trade by a few minutes, as investors welcomed signs that its business is stabilizing.

Dell, which was stung earlier and more acutely than some other large IT firms by the downturn in enterprise spending, said it expects second-half revenue to come in stronger than the first, assuming current trends hold.

It also continued to sound bullish on a robust corporate refresh cycle starting next year, as big companies move to replace aging hardware.

The results were strong across the board. You had revenue upside, gross margin upside, and of course earnings upside, said Ashok Kumar, analyst at Collins Stewart.

They were faced with a fairly difficult demand environment, along with pricing pressure, and it seems the company was able to navigate the those cross currents fairly successfully.

Analysts credited better-than-expected margins for the surprising results, after Dell warned just six weeks ago that higher component costs and a competitive pricing environment, would eat into margins.

But Dell reported gross margins of 18.7 percent, thanks to cost cuts, what it called disciplined pricing, an increase in enterprise sales from the first quarter and a $69 million buyout of a revenue-sharing agreement by a vendor.

Wall Street had expected 17.7 percent.

Obviously it's a better-than-expected performance on the gross margin side, said Richard Kugele, analyst at Needham & Co.

Slow, steady progress right now is good enough as far as I'm concerned.

On a conference call with analysts, Chief Executive Michael Dell said the company is expecting a strong replacement cycle starting in 2010, helped in part by Microsoft's new Windows 7 operating system, which is due in October.

It's not all going to come in the first month or the second month, but over the course of the year, there will be a big refresh cycle.

For its second quarter, which ended July 31, Dell reported a net profit of $472 million, or 24 cents a share, down from $616 million, or 31 cents a share, in the year-ago period.

Excluding items, the company earned 28 cents a share, beating analysts' average estimate of 23 cents a share, according to Reuters Estimates.

Revenue fell 22 percent to $12.8 billion. Still, that was ahead of Wall Street's estimate of $12.6 billion.

Dell's enterprise businesses continued to struggle, while the public and consumer segments -- where units rose 17 percent -- showed more strength. The U.S. and Asia were stronger than Europe.

Laptop shipments were roughly flat, while revenue fell 21 percent. Desktop units fell 23 percent as revenue declined 33 percent. While the bulk of Dell's business comes in PCs, the company said it is gaining share in servers and storage.

Dell trails Hewlett-Packard in global PC shipments and is feeling the pressure from No. 3 Acer Inc, which is growing quickly thanks in part to strong netbook sales.

Earlier Thursday, Acer reported weaker quarterly results even as it sold more PCs, underscoring how low-cost netbooks are cannibalizing sales of its more expensive products.

COST CUTS

Dell has been shedding jobs and cutting billions in costs to realign its business, and is working to shift its product base to higher-margin offerings and recurring revenue streams through partnerships and acquisitions.

For now, Dell remains heavily reliant on computer sales to small, medium and large businesses. Its finance chief cautioned that corporate budgets are pretty much set and thus enterprise demand would remain challenging.

But on a conference call with reporters, Chief Financial Officer Brian Gladden said there were some pockets of improved demand, particularly in the consumer sector.

Consumer will continue to be pretty good for as we continue to gain share there and I think those markets are improving, he said.

Shares of Round Rock, Texas-based Dell closed up 6.7 percent at $15.65 on Nasdaq and rose another 2.7 percent in extended trading to $16.08.

(Reporting by Gabriel Madway; Additional reporting by Ritsuko Ando in New York; Editing by Richard Chang and Steve Orlofsky)