“Walmart.com has been severely mismanaged,” Mr. Flickinger said. “Walmart would go a few years and invest strategically and significantly in e-commerce, then other years it wouldn’t,” he said. “Meanwhile, Amazon is making moves in e-commerce that’s put Walmart so far behind that it might not be able to catch up for 10 more years, if ever.”

Looking up at the leader is an unfamiliar perch for Walmart, which for decades had dominated retailing with a vast supplier network, stripped-down supercenters and rock-bottom prices. Before Amazon, Walmart was the retailer that undercut everyone else with impossible-to-beat prices and hefty scale, muscling them out of business.

But despite declaring a decade and a half ago — in 1999 — that Walmart.com was a priority for the company, the retailer has failed to translate its dominance in stores to online shopping. For years, it has struggled to figure out how to best deliver fresh food and groceries.

It hired Jeanne P. Jackson, an e-commerce pioneer and former chief executive of Banana Republic and head of online operations at Gap, to overhaul its online presence. But Walmart’s then-notoriously insular, and by some accounts, male-dominated culture, drove Ms. Jackson away in less than two years. Gradually, market anticipation that Walmart would become a viable competitor to Amazon dissipated.

In the meantime, Amazon beat one rival after another, dropping prices by double-digit percentages to undercut newcomers and swiftly driving them out of the market.

Mr. McMillon, a Walmart veteran who took the helm at the retailer last year, wants to again put e-commerce front and center, pledging to invest $1 billion in its online operations this year. Under Mr. McMillon, Walmart has expanded the number of products sold on Walmart.com to seven million from one million just three years ago. That number is set to rise to 10 million by the end of the year, though that is a fraction of the estimated 300 million items for sale on Amazon.