By Nandita Bose

(Reuters) - Wal-Mart Stores Inc <WMT.N> reported higher-than-expected quarterly earnings on Thursday, saying it benefited from cleaner and more efficient U.S. stores, investments in technology that improved online shopping and higher employee wages that fostered better customer service.

The world's largest retailer has been spending heavily to entice consumers back to its stores with better stocked shelves, and improving its e-commerce business by investing in new warehouses that can deliver online shipments faster. Last week, it announced the acquisition of online startup for over $3 billion to better compete with Inc <AMZN.O>.

Wal-Mart also increased entry level wages to $10 an hour earlier this year and said it will invest $2.7 billion in employee compensation and training over two years, a move it said contributed to improved service in its stores.

These steps, analysts said, helped Wal-Mart to raise its fiscal-year forecast and buck a string of weak results from higher-end brick-and-mortar competitors like Target Corp <TGT.N>, Macy's Inc <M.N> and Kohls Corp <KSS.N>. Target cut its fiscal-year profit outlook on Wednesday after quarterly sales fell more than expected.

Wal-Mart U.S. Chief Executive Officer Greg Foran said on a conference call that the company's customers were still cautious with their spending but were visiting stores more often and buying more items. Store visits increased 1.2 percent, and the average size of an order rose 0.4 percent during the second quarter ended on July 31.

"We are seeing a steady improvement in the U.S. business, and it is responding favorably to the changes we are making," he said.

The Bentonville, Arkansas-based company said sales were strong for grocery items and apparel but weak for electronics.

"Walmart's strategic investments are generating traction, which is especially meaningful, given a large portion of its customer base remains challenged," said Moody's analyst Charlie O'Shea.

The retailer said it was difficult to quantify the effects of low gasoline prices and unseasonably warm weather, but those factors contributed to overall sales growth.

Online sales growth accelerated sequentially for the first time in more than five quarters, rising 11.8 percent from 7 percent in the first quarter.

Chief Financial Officer Brett Biggs said e-commerce growth was stronger in the United States than in major overseas markets, mainly because of its larger third-party seller business and the continued roll-out of online grocery pickup options.

Wal-Mart has added 7 million items to its website this year, bringing the total to 15 million. This compares with 200 million on online rival Inc <AMZN.O>.

The company raised its fiscal-year earnings outlook to between $4.15 and $4.35 a share, including an estimated hit of 5 cents from the acquisition, from a previous range of $4 to $4.30.

Second-quarter earnings per share of $1.07, excluding a gain from the sale of Wal-Mart's e-commerce business in China and other items, exceeded the analysts' average estimate by 5 cents.

Sales at U.S. stores open at least a year rose 1.6 percent, excluding fuel prices, to beat expectations in their eighth straight quarter of growth.

International sales fell 6.6 percent to $28.6 billion but increased 2.2 percent on a currency-neutral basis. Total revenue rose 0.5 percent to $120.9 billion.

Wal-Mart's shares rose as much as 2.8 percent earlier in the trading day. They were up 1.8 percent at $74.23 in afternoon trade.

(Additional reporting by Sruthi Ramakrishnan in Bengaluru; Editing by Lisa Von Ahn)