Fresh off a successful push into online grocery pickup, the country's biggest retailer is taking things to the next level. Walmart (WMT -0.65%) is rolling out a grocery delivery service over the next few months that will allow almost half of the U.S. population to have their food orders brought right to their homes.

It's an expensive strategy that's likely to hurt profitability in both the short and long term. But Walmart is happy to accept slightly lower earnings in exchange for the sales boost the move should provide.

Let's take a closer look.

Going for growth

Walmart already has a pickup option for digital grocery store orders at about 1,000 of its retailing locations and is set to double that footprint by the end of the year. In addition, delivery functionality is rolling out right now, with plans for the service to reach 800 stores by 2019. That would put 40% of the population within reach of a Walmart grocery delivery over the next few months.

Market-share defense plays a role in this move, since peers like Kroger (KR 0.56%) are making similar moves into delivery. Amazon.com (AMZN -1.14%), meanwhile, is using its Whole Foods locations to dramatically scale up its presence in the market.

Walmart says this move is about offense, too, since customers who shop through its online channels tend to be more valuable to the business.

They buy about twice as much as shoppers who limit their spending to in-store purchases, management estimates. These tech-savvy customers also end up shelling out more money at stores once they become e-commerce clients, Walmart has noticed.

Man looking at a product in a grocery aisle.

Image source: Getty Images.

Its latest results back up those claims. Walmart's 33% e-commerce spike last quarter significantly lifted sales at existing locations. These comparable-store sales gains would have been 1.1% but landed at 2.1%, thanks mainly to strength in home delivery and online grocery orders. Customer traffic trends held up well, too.

Not a win-win

The digital transformation strategy has some major drawbacks, mainly revolving around costs. Walmart revealed another decline in profitability last quarter that was driven by the extra e-commerce transportation expenses, for example. Spending also rose as the retailer built out its online selling infrastructure. Overall, operating income fell 3% in the U.S. market, which pushed operating profit lower.

Walmart has plenty of company here. Target (TGT 1.28%) and Kroger have both warned investors in recent quarters that they should expect profitability to decline as their businesses shift more toward online sales. All three retailers have announced big reductions in operating margin in the past two years, even though sales volumes and customer traffic levels have been positive.

WMT Operating Margin (TTM) Chart

WMT Operating Margin (TTM) data by YCharts.

Like its rivals, Walmart believes the profit slump will stabilize soon before a modest recovery starts. As support for this outlook, executives like to point out how enthusiastically people are flocking to digital options like in-store pickup and delivery. "Customers love to have choices in how they shop," CEO Doug McMillon said in a recent conference call, "and we're positioning to serve them well."

Catering to shopper demands is the right long-term choice for Walmart, and it's a big reason why the company is aggressively expanding into grocery delivery. The trouble is that rivals are all racing into the niche, too. That fact, combined with the tough economics around fulfilling low-margin food orders, suggests Walmart's dominant market position won't protect it from a continued profitability pinch as its grocery service rolls out nationwide.