Gap Inc posted a slightly stronger than expected quarterly profit on Thursday as more full-priced sales, inventory controls and cost cuts helped offset declining revenue at all its chains.

The company behind the Gap, Old Navy and Banana Republic chains -- whose shares are up 39 percent since January -- has improved profit margins even as slumping sales pressured results.

Net income for Gap's fiscal second quarter ended August 1 fell to $228 million from $229 million a year earlier. Earnings per share were 33 cents, up from 32 cents a year earlier, when there were more shares outstanding.

Analysts on average expected 32 cents per share according to Reuters Estimates.

Revenue fell 7 percent to $3.25 billion. Analysts were expecting $3.26 billion.

Same-store sales, a key gauge of retail performance, fell 8 percent in the quarter versus 10 percent a year earlier.

Gap stores saw a 10 percent decline in same-store sales, while Banana Republic, a more upscale chain that sells clothing to young professionals, recorded a 15 percent drop.

At Old Navy, the company's largest division in terms of total sales, same-store sales fell 4 percent as recent merchandise improvements and value-priced goods lured new shoppers.

Gap has boosted margins by streamlining its organization, reducing inefficiencies in its supply chain and cutting costs. But analysts believe these efforts -- which have offset a lingering sales slump -- will be more difficult to continue in coming quarters.

In the second quarter, operating costs fell by $52 million from the year-ago quarter, but those costs are likely to be flat or rise about $20 million in the third quarter due to more marketing, Gap said.

Gross margin as a percentage of total sales rose to 39.7 percent from 38.2 percent, an improvement of 150 basis points.

Last week, the Gap chain launched a major denim campaign, offering jeans with better fits and higher-end styling in hopes of bringing back once-loyal customers who gravitated to more fashionable rivals.

San Francisco-based Gap has not provided a full-year profit outlook since last year.

(Reporting by Alexandria Sage; Editing by Steve Orlofsky)