NEW YORK (Reuters) - Walmart Inc on Thursday said profit margins during the first quarter remained under pressure due to price cuts and higher freight costs, weighing on its shares even as sales and earnings came in stronger than expected.

Walmart’s gross margin, which has fallen for four consecutive quarters, was down 23 basis points in the quarter ended April 30. Within the U.S. division, operating income fell 3.1 percent from the prior year.

Shares of the world’s biggest retailer traded 1.6 percent down in afternoon trade after initially opening higher. The stock has fallen around 20 percent from an all-time high in January.

“The Street is trying to digest the margin performance and there are concerns around when they can make money given the large investments in e-commerce,” said Brian Yarbrough, an analyst with Edward Jones.

The weak margins overshadowed strong first-quarter results and progress in Walmart’s efforts to keep pace with rivals like Amazon.com Inc.

Walmart’s e-commerce sales grew 33 percent, above the 23-percent growth in the previous three months. It said it is on track to increase U.S. e-commerce sales by 40 percent for the full year.

The e-commerce rebound comes after a sharp slowdown during the crucial holiday quarter, which sent its shares down over 10 percent and wiped out $31 billion from its market capitalization.

“Online grocery continued to accelerate and we also have new brands in e-commerce including the partnership with Lord and Taylor, so there are a lot of different things driving growth there,” Chief Financial Officer Brett Biggs said in an interview. He said free two-day shipping boosted growth, and the Walmart.com site redesign helped late in the quarter.

The site redesign also boosted traffic to the company’s online grocery business by 10 percent to 20 percent, e-commerce chief Marc Lore told reporters on an earnings conference call.

FILE PHOTO: The logo of Walmart is seen on shopping trolleys at their store in Sao Paulo, Brazil February 14, 2018. REUTERS/Paulo Whitaker/File photo

INTERNATIONAL BOOST

International sales were up 4.5 percent at $28.3 billion on a constant currency basis, helped by an early Easter, Biggs said.

The company is in the process of fixing its international business portfolio and recently said it will acquire a 77-percent stake in Indian e-commerce firm Flipkart for $16 billion, its largest deal ever, to compete with Amazon.com Inc in an important growth market. It plans to sell a majority stake in its UK grocery chain Asda Group Ltd to J Sainsbury PLC.

Walmart also recently reached agreements to sell its banking operations in Walmart Canada and Walmart Chile, it said on Thursday.

Excluding special items, adjusted earnings were $1.14 per share. The average analyst estimate was $1.12 per share, according to Thomson Reuters I/B/E/S.

Sales at U.S. stores open at least a year rose 2.1 percent excluding fuel, in line with analyst forecasts, according to Consensus Metrix. Walmart has recorded nearly four straight years of U.S. growth, unmatched by any other retailer.

Walmart said some consumers may have felt the pinch from rising gas prices, but consumer demand remained robust.

“In terms of (demand), this quarter is reasonably similar to what I have seen last year and we are comfortable with our strategy,” Walmart’s U.S. CEO Greg Foran said on a media call.

The comparable sales increase was driven by a jump in the price of items sold and by e-commerce. The company’s U.S. grocery business and higher branded drug prices also boosted growth.

Competition in the U.S. grocery sector intensified as rival Kroger Co struck a deal with British online grocery company Ocado Group to build and deliver groceries from robot-staffed warehouses.

Customer traffic at Walmart stores was up 0.8 percent during the quarter, slower than the 1.5 percent growth during the same period a year ago. A delayed spring hurt demand in weather-related categories and led customers to consolidate trips.

Biggs said demand in those categories rebounded this month.

Total revenue increased 4.4 percent to $122.7 billion, beating analysts’ estimates of $120.5 billion.