Amazon.com (NASDAQ:AMZN) may own the online grocery segment at the moment, but Walmart (NYSE:WMT) is rapidly expanding its capabilities, which could lead to the supermarket giant toppling the e-commerce leader by the end of the year.

This article originally appeared in the Motley Fool.

Deutsche Bank says Walmart is so strategically invested in its online business compared to its physical stores that it "is best positioned to continue to take both mind and market share going forward."

Walmart already has about 2,000 stores that facilitate curbside grocery pickup service, and another 1,000 will come on line by the end of next year, executives said at a recent investor conference. Using its own services as well as those from providers like DoorDash, Deliv, and a trial project with Alphabet's self-driving car subsidiary Waymo, Walmart will have the ability to reach 40% of the U.S. population with online grocery delivery.

Online grocery shopping still an untapped opportunity

The potential for online grocery shopping is huge, if for no other reason than that most U.S. consumers haven't tried it yet.

In a recent TABS Analytics survey, only 17% of respondents said they regularly shop online for groceries, meaning they buy groceries that way at least six times a year. That's 4 percentage points more than last year, but still represents a modest gain, given that 62% of survey participants said they never buy groceries online.

The survey also found that online grocers need to do more to ensure success, as just 44% of online grocery shoppers are loyal to the format, well below the 75% needed to ensure the channel's viability. TABS Analytics president and founder Dr. Kurt Jetta said, "This format has a long way to go to achieve a stable demand; until then eComm grocery will be relying on having to invest in expensive trial-generating activities."

Amazon is tops, but maybe not for long

Online grocery shopping is ripe for disruption, and Walmart's positioning couldn't be better-timed. While it is not exactly faltering, Amazon is not seeing the kind of payoff it likely expected in the grocery space, particularly after buying Whole Foods Market. The e-commerce giant faces slowing growth across many of its businesses, but Amazon Fresh especially is suffering from tepid sales, which caused Amazon to scale back that service's presence in several states last year. Prime Pantry growth is also leveling out.

Amazon held a 12.5% share of the online grocery industry in 2017, followed by Walmart with 11.1%, and Kroger a distant third at 6.4%. Target trailed in eighth place with just a 1.8% share. The Deutsche Bank analyst, however, sees Walmart surpassing Amazon by year's end and growing its share to 17% by 2025. But it's not a static market, and Amazon is expected to retake the top spot by then with a 19% share.

Key takeaway

Online grocery sales are on track to become one-fifth of the U.S. grocery retail market by 2025, with about $100 billion in annual sales. Although Walmart is ready to take the seat at the head of that table, the crown won't rest easy on the head of whoever is sitting there. This is a two-horse race that could see the lead change hands frequently, and it may soon become Walmart's race to lose.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Suzanne Frey, an executive at Alphabet, is a member of The Motley Fool's board of directors. Rich Duprey has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Alphabet (A shares), Alphabet (C shares), and Amazon. The Motley Fool has a disclosure policy.

Walmart A woman shops at Walmart near the Green Acres Mall in Valley Stream, NewYork, Nov. 24, 2017. Photo: Stephanie Keith/Getty Images