It's easy to think that with Amazon.com (NASDAQ:AMZN) coming under criticism from the White House over its relationship with the U.S. Postal Service, its impact on brick-and-mortar retail, and its tax collection policies, it presents an opportunity for rival Walmart (NYSE:WMT) to capitalize on its rival's distraction and gain ground. Yet whatever advantage the retail king might gain, the window to seize it is constantly narrowing.

This article originally appeared in the Motley Fool.

Rather than a silver bullet, Walmart needs a more holistic approach to taking on its greatest threat. The good news for Walmart is there is reason to believe it's Amazon's only competitor that can actually thwart the ecommerce company's attempt at complete retail dominance.

Size matters

On the surface, it shouldn't even be a contest. Walmart's annual sales total $500 billion compared to $178 billion for Amazon, but when we look at the all-important e-commerce portion of sales, the situation is reversed. Walmart generates almost $19 billion in online sales; Amazon, $113 billion.

Walmart has done an incredible amount of work to narrow the gap and shore up its deficiencies in that space, most notably buying Jet.com in 2016 for $3.3 billion. The purchase initially helped grow digital sales by 50% to 60% rates, but the market took it to task after it reported fourth-quarter e-commerce sales growth of only 23%.

However, Walmart is in the process of positioning its business for the future by scooping up women's wear retailer Modcloth, menswear outlet Bonobos, shoe store Shoebuy, and outdoor apparel maker Moosejaw. At the same time, it's partnered with Hudson's Bay's Lord & Taylor chain to sell its merchandise on its website, taken a sizable stake in Chinese e-commerce marketplace JD.com, and launched a private label apparel line through Jet.com called Uniquely J to further tap into millennial shoppers.

These moves show that Walmart is branching out beyond simply the price-sensitive shopper, one that Amazon itself initially appealed to, and is willing to offer a broader selection of goods that strike a chord with a wider audience.

A winning bricks-and-mortar strategy

Certainly, there are risks in this approach, not least because Walmart isn't necessarily viewed as the go-to alternative for online shopping. Amazon.com is the default choice for most people, but Walmart has a much bigger arrow in its quiver in the form of its massive store footprint. Even after the acquisition of Whole Foods Market gave Amazon a few hundred stores to experiment with, Walmart's 4,700 U.S. stores give it a chance to better blend the online and offline worlds.

Buy online pickup in store, or BOPIS, could be a deciding factor in Walmart's ability to thwart Amazon's advance. It forecasts that online sales will grow 40% this year, and it offers customers discounts if they choose the in-store option of picking up their purchases.

Walmart is encouraging customers to do just that by expanding the availability of what it calls Pickup Towers, automated kiosks that seem akin to Amazon Lockers, which allow customers to pick up orders in stores at their own convenience. Walmart currently has Towers installed in 200 stores, but it plans to have as many as 700 by the end of the year, which it says will make them available to nearly 40% of the U.S. population.

Feeding the future

Walmart is also not ceding ground in groceries, where it is currently the leader, but there is widespread fear Amazon will overtake everyone. Walmart is planning to double the number of U.S. curbside locations for online grocery shoppers at its stores, with as many as 1,000 stores currently participating in the program.

It's also partnered with Google to initiate voice-activated shopping through Google Assistant and Google Express, allowing customers to shop for some two million Walmart items online. And it just partnered with PostMates to offer same-day grocery delivery. It's starting in Charlotte, North Carolina, and expanding to 100 other metro areas in the coming months.

While Amazon.com holds a seemingly insurmountable lead in e-commerce, that doesn't mean Walmart can't narrow the gap between them. The retail king has long been a tech leader, and it has both the capabilities and the financial wherewithal to take on Amazon.com.

Walmart's operating and net margins are typically twice that of Amazon, and it has the benefit of an installed base of stores that it can use as distribution hubs to attract more customers. 

Perhaps there are some gains to be made in the current political environment, but Walmart's best chance of success in becoming even more relevant to online shoppers is not found in a single moment of peril for its rival but through a broad range of programs that challenge and pressure Amazon.com head on. Walmart looks like it can achieve it.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, 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 Amazon. The Motley Fool has a disclosure policy.