The retailer's profits, however, continued to be under pressure. Margins were impacted as Walmart absorbed higher transportation costs and invested heavily in its online business.

Walmart's shares, which traded up premarket and opened higher, reversed course in early trade. Shares were down 1.04 percent at $100.47 per share as investors were spooked by poor performance from J.C. Penney and Dillard's Inc, turning bearish on retail stocks, analysts said.

Strong consumer spending has helped many brick-and-mortar retailers post solid sales gains this quarter, ahead of the key U.S. holiday season even as e-commerce investments have gnawed away profits.

"Fresh (food) continues to do very well but there is strength across the board from a category standpoint," Chief Financial Officer Brett Biggs told Reuters in an interview.

Grocery sales make up 56 percent of Walmart's revenue, and at its investor day last month Walmart's Chief Executive Doug McMillon emphasized Walmart's advantage in the food category, an area that rival Amazon.com Inc is trying to crack, particularly following its acquisition last year of organic grocer Whole Foods. McMillon said Walmart can offer fresh food within 10 miles of 90 percent of the U.S. population.

The company has expanded its grocery pickup program, which allows customers to order online and pickup at 2,100 of its U.S. stores. Walmart will also add grocery delivery services to about 800 stores by the end of the year, the retailer's U.S. CEO Greg Foran said.

Walmart will overtake Apple Inc as the third largest e-commerce retailer by sales this year, behind Amazon and eBay Inc, according to data released Thursday by market research firm eMarketer. Walmart is expected to grab 4 percent of U.S. e-commerce sales, or about $20.9 billion, up from 3.3 percent last year, eMarketer said.

Walmart's sales at U.S. stores open at least a year rose 3.4 percent in the third quarter, excluding fuel price fluctuations, higher than analysts' estimates of a 2.87 percent increase, according to IBES data from Refinitiv.

Walmart has recorded over four straight years of U.S. growth, unmatched by any other retailer.

E-commerce sales soared 43 percent, topping the 40-percent growth in the previous quarter. The retailer has said it is on track for e-commerce sales to rise by 40 percent this year.

The retailer has also been on an acquisition spree, buying brands aimed at millennial shoppers who typically don't shop on the retailer's website. Walmart recently bought lingerie retailer Bare Necessities after purchasing plus-sized clothing startup Eloquii a week earlier.

The company's e-commerce business is expected to post a slightly greater operating loss next year, the retailer said during investor day.

Walmart's international sales grew 1.6 percent to $30 billion excluding currency impact. In India, one of its key overseas markets, Walmart suffered a setback on Tuesday when the chief executive officer of its Indian e-commerce business Flipkart Group, resigned following an allegation of sexual assault.

Walmart paid $16 billion for a roughly 77-percent stake in Flipkart in May, its biggest acquisition and a major move in competing against Amazon.

Walmart's quarterly total revenue increased 2.4 percent to $126.1 billion, excluding currency changes, beating analysts' estimates of $125.56 billion.

Adjusted earnings came to $1.08 per share, above expectations of $1.01. Consolidated net income attributable to Walmart for the third quarter stood at $1.71 billion versus $1.75 billion a year ago.

Walmart raised its adjusted earnings outlook for fiscal year 2019 to $4.75 to $4.85 per share from $4.65 to $4.80. It also said it expects comparable sales, excluding fuel, to grow "at least" 3 percent, a change from "about" 3 percent earlier in fiscal 2019.

(Reporting by Nandita Bose in New York; Editing by Jeffrey Benkoe and Nick Zieminski)

By Nandita Bose