Walmart
The Walmart logo is seen on a store in Washington, D.C., March 1, 2019. Walmart is now using virtual reality headsets to find out which of its employees have the aptitude to take on  managerial roles. The VR skills assessment is part of the company’s selection process to find new middle managers. NICHOLAS KAMM/AFP/Getty Images

2018 could go down in the books as a turning point in Walmart's (NYSE:WMT) business. After many years of online irrelevancy, followed by several years of intense investing in online sales capabilities and a string of acquisitions of online-only stores, the world's largest retailer now has a viable e-commerce business. Walmart's success comes in spite of recent worries about global economic slowdown, a trade war between the U.S. and China that could hit consumers in the wallet, and plenty of competition in the world of digital selling.

Amazon (NASDAQ:AMZN), on the other hand, continues to cool off in that department. E-commerce is still squarely in Amazon's control, but size and success often come with a target. Walmart has been increasingly willing to go head-to-head with Amazon, and its brand of online retail is narrowing the gap with the younger disruptive Amazon.

A tale of two retailers

During the first quarter of 2019, Walmart's U.S. business put up comparable-store sales growth of 3.4% -- the best rate in nine years -- for a grand total of $80.3 billion in net revenue. And 1.4% of that total growth was due to the e-commerce segment, which includes order-online pickup in-store. While still a relatively small part of the total operation, Walmart said its e-commerce sales surged 37% higher compared to a year ago.

By comparison, Amazon's numbers were pedestrian. Sales from online stores increased 10% to $29.5 billion. Meanwhile, stores from physical stores (which include the Whole Foods subsidiary) were up a meager 1% to $4.3 billion after falling 3% in the fourth quarter.

Walmart-Amazon
Ecommerce growth at Amazon and Walmart. Data source - Walmart and Amazon

What does all of this mean? According to the U.S. Census Bureau, e-commerce grew 10.4% during the first four months of 2019. That means Amazon is still growing, but it's in line with the total U.S. nonstore retail industry overall. It's Walmart that is posting above-average expansion. Amazon, once a thorn in Walmart's side, is losing steam. Now Walmart is closing ground and retaking some of its lost market share via the digital channel.

Two very different stocks

For investors looking for retail stocks, Walmart looks like the better bet right now. The online business the company is building on top of its physical footprint is winning with U.S. consumers, and Walmart is investing heavily in overseas retail too -- including its majority-owned stake in India's largest e-commerce site Flipkart and a partnership with Japan's Rakuten. Walmart's stock is currently valued at 19.2 times trailing 12-month free cash flow and pays a 2.1% annual dividend.

That doesn't mean Amazon is chopped liver. Though its retail business isn't what it used to be, the company is using its leadership in digital selling to grow in other areas. Online advertising, for example, was a $2.7 billion segment in the first quarter, up 34% year over year. And then there's the cloud computing business Amazon Web Services, as well as other subscription services (like Amazon Prime, Video, and Music), both of which grew 41% and 40%, respectively. The two reported divisions combined for a $12 billion haul during the quarter.

Thus, Amazon is still the better growth stock here. But as far as e-commerce is concerned, it's time to start giving credit where credit is due to Walmart. An insignificant internet enterprise just a few years ago, the big-box store is now a force to be reckoned with when it comes to the future of shopping.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Nicholas Rossolillo and his clients have no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy.

This article originally appeared in The Motley Fool.