CHICAGO (Reuters) - Wal-Mart Stores Inc warned on Thursday that this quarter’s earnings could miss Wall Street’s estimates as the world’s biggest retailer struggles with falling margins due to price-cutting and heavy spending on its e-commerce operations.

The company’s shares fell more than 2 percent, with investors shrugging off a higher full-year profit outlook and sales that defied sluggish consumer demand that has hurt many rivals. Wal-Mart has reported three straight years of comparable sales growth as more people shop at its stores and on its websites.

With a steady rise in the number of people who buy online, e-commerce sales growth has been outstripping brick-and-mortar.

Like other retailers, Wal-Mart has been aggressively investing in its e-commerce business in the past year. It has begun offering programs like free-two-day shipping and discounts for picking up online purchases at stores, and it acquired several startups, including Jet.com for $3.3 billion last year.

The company’s online sales growth outpaced the industry at 60 percent in the second quarter ended on July 31 but decelerated from the 63 percent increase of the previous quarter. Wal-Mart said most of the growth had come from its own online business and not the acquisitions it has made in the past year.

Wal-Mart has also been cutting grocery prices to remain competitive against discounters like Germany’s Aldi Inc, which is rapidly expanding in the United States, and Lidl, another German rival that has recently started opening stores in the country.

Given Wal-Mart’s moves, margins may contract for the rest of the year, UBS said in a note to clients.

Shopping carts are seen outside a new Wal-Mart Express store in Chicago July 26, 2011. Wal-Mart Stores Inc reporterd a higher-than-expected quarterly profit May 19, 2106, as sales in the U.S. market rose, sending the retailer's shares up nearly 10 percent. REUTERS/John Gress/Files

But despite the earnings warning and pressure on margins, most analysts remained bullish on Wal-Mart because of its sales performance.

“The second-quarter numbers show that Wal-Mart remains firmly on the front foot and is more than holding its own in a challenging and competitive retail market,” said GlobalData Retail Managing Director Neil Saunders.

Second-quarter sales at U.S. stores open at least a year rose 1.8 percent, excluding fuel price fluctuations and including e-commerce. That exceeded market expectations for a 1.7 percent increase, according to research firm Consensus Metrix.

The company cited its grocery and food business, which reported its best performance in five years, and said its online operation added 70 basis points to comparable sales.

U.S. store visits were up 1.3 percent from 1.2 percent a year earlier.

Total revenue increased 2.1 percent to $123.4 billion from a year earlier. It would have been up 2.9 percent without the effects of currency fluctuations, which the company said had diminished from previous quarters.

Net income attributable to Wal-Mart fell 23 percent to $2.9 billion due to a loss from repurchasing debt after a bond tender offer. Excluding special items, earnings per share of $1.08 exceeded the analysts’ average estimate of $1.07, according to Thomson Reuters I/B/E/S.

Gross margins were down 11 basis points at 25 percent, including a five-basis-point decline in the United States, compared with analysts’ expectations of 25.22 percent.

Operating margins fell to 4.9 percent from 5.1 percent, and U.S. operating expenses rose 3.9 percent.

The company said it expected third-quarter earnings of 90 cents to 98 cents a share, excluding special items. Analysts on average had forecast 98 cents.

Wal-Mart raised the low end of its earnings outlook for the full year to $4.30 per share from $4.20, excluding items, while keeping the high end at $4.40.