Wal-Mart Stores Inc's decision to absorb most of the rising food costs for its stressed U.S. shoppers and spend on its e-commerce business weighed on profitability, even as key U.S. sales rose for the first time in more than two years.

Sales at U.S. discount stores open at least a year rose more than expected in the third quarter ended on October 31, ending a string of nine straight quarterly declines. Same-store sales have now risen for four months in a row.

But visits to stores were once again down from a year earlier, even as shoppers, on average, spent more per visit.

The results coincided with government reports that U.S. retail sales rose 0.5 percent in October, while wholesale prices fell 0.3 percent.

Walmart U.S., the largest division of the world's largest retailer, held off on raising prices as much as it could to appeal to cost-conscious shoppers who remain concerned about the job market and overall economy.

They were clearly being aggressive in pricing and gaining share, but they didn't get the leverage on the cost side, said ITG Investment Research analyst John Tomlinson. He said the company might look for more price givebacks from vendors.

Groceries cost Walmart U.S. about 4 percent more during the quarter. But Walmart saw inflation of only 0.7 percent across the entire store due to deflation in areas such as televisions, price cuts and customers trading down to less expensive options, said U.S. Chief Executive Bill Simon.

Shares of Wal-Mart were off 2.7 percent at $57.29 in late morning trading on Tuesday.

The shares had been rising heading into the quarterly report, after Wal-Mart said in mid-October that U.S. same-store sales had continued to rise early in the period.

Same-store sales account for about 98 percent of Wal-Mart's sales in the United States, so ending the slump at existing stores is critical for the company, as its international business has not grown as rapidly as some anticipated.

Walmart's customers remain worried about the U.S. job market, CEO Mike Duke said on a recorded call. The company's survey of mothers found that only one out of 10 viewed the economy as good, he said.

Walmart has been ratcheting up efforts to reach shoppers through the Web and mobile apps, but those measures are coming at a cost. Unallocated corporate overhead and other expenses jumped about 40.7 percent to $536 million, due largely to investment in e-commerce, Treasurer Jeff Davis said on the call.

U.S. TURNAROUND

Walmart U.S. same-store sales rose 1.3 percent. That topped the company's forecast, which called for such sales to be down 1 percent to up 1 percent. It also exceeded the analysts' average forecast for a rise of 0.3 percent, according to Thomson Reuters data.

Walmart is offering holiday season layaway for the first time in years and advertising its low prices more than usual as it tries to win back shoppers who have flocked to competitors including Dollar General Corp.

The most popular toy on layaway so far has been LeapFrog Enterprises Inc's LeapPad, Simon said. The gadget, which is like a tablet computer for kids, is priced at about $99.

Retailers account for a layaway sale when the customer pays for the item in full and picks it up, so most layaway purchases at Walmart will not count as sales until the fourth quarter.

Walmart, which has been open on Thanksgiving for years, will start its big sales at 10 p.m. that night. It has also lowered some prices weeks before Black Friday, the day after Thanksgiving and the traditional kick-off to the holiday shopping season.

Wal-Mart earned $3.34 billion, or 97 cents per share, from continuing operations in the third quarter, compared with $3.44 billion or 95 cents per share a year earlier, when a tax benefit lifted profit by 5 cents per share. There were fewer shares outstanding during the most recent quarter.

The company had forecast a profit of 95 cents to $1.00 per share. Analysts on average expected 98 cents, according to Thomson Reuters I/B/E/S.

Net sales rose 8.2 percent to $109.5 billion.

Meanwhile, Home Depot Inc raised its profit outlook, TJX Companies Inc increased its holiday same-store sales forecast, Staples Inc cut its profit view and profit at Saks Inc topped expectations.

Wal-Mart forecast fourth-quarter earnings of $1.42 to $1.48 per share from continuing operations. Analysts on average forecast $1.45.

It expects Walmart U.S. same-store sales to be flat to up 2 percent after falling 1.8 percent in last year's fourth quarter. At Sam's Club, same-store sales excluding fuel should rise 4 to 6 percent after a 2.7 percent rise last year.

(Reporting by Jessica Wohl in Chicago; Editing by Lisa Von Ahn, John Wallace and Matthew Lewis)