(NASDAQ:AMZN) has spent billions of dollars in recent years to rapidly expand its network of distribution centers. Using robots to wring out every ounce of inefficiency, the e-commerce king has developed a meaningful advantage over traditional retailers. Companies such as Wal-Mart (NYSE:WMT) and Target (NYSE:TGT) have spent decades building vast distribution networks of their own, but these are designed to put products into stores, not on people's doorsteps.

Source: Amazon.

Now, both Wal-Mart and Target are turning to online sales in an effort to counteract weak in-store performance. While both companies have built distribution centers specifically for fulfilling online orders -- Wal-Mart expects to spend about $1.5 billion on e-commerce initiatives this year -- these networks still pale in comparison to the scope of Amazon's operations.

But traditional retailers have a weapon in this battle that the online retailer simply can't match, and both Wal-Mart and Target are now just starting to realize its potential. The very thing that is often assumed to be a liability in the age of e-commerce -- physical stores -- is actually becoming a valuable asset.

Turning stores into distribution centers
Shipping online orders directly out of stores isn't a new idea. Macy's has been doing it for a few years, and Best Buy expanded its ship-from-store program to great success. Wal-Mart started testing the idea in 2012, and it currently ships online orders out of 83 Supercenters. Target just started in 2014, and 136 of its stores are now equipped to fulfill online orders.

Amazon's robot-filled warehouses may be more efficient, but the ship-from-store initiative comes with three major advantages.

First, it allows Wal-Mart and Target to expand their e-commerce businesses using existing assets. Both companies are still actively building online distribution centers, of course, but ship-from-store allows the retailers to spend less while developing the necessary capacity to grow their online sales. Wal-Mart guided for $12.5 billion in total e-commerce sales in 2014, and it expects to boost this number by 25% in 2015 and by as much as 40% annually through 2018. Currently, about 20% of Wal-Mart's e-commerce business goes through the aforementioned 83 Supercenters.

Second, ship-from-store opens the inventory of stores to the e-commerce channel. Best Buy, for example, accelerated its online sales growth in part by reducing the number of instances in which items were out of stock online. When an item is out of stock at Wal-Mart or Target's online distribution centers, there's a good chance it is sitting on a shelf at a store location somewhere near the customer.

As Wal-Mart and Target expand their ship-from-store programs, the primary challenge will be logistical -- keeping track of inventory across the various channels and routing online orders to the most appropriate location. But the payoff could be significant, with fewer online customers abandoning their orders due to unavailable items.

Lastly, ship-from-store has the potential to greatly reduce shipping times. Already, Wal-Mart has increased its online shipping speeds by 15% since 2012, and the gains will only grow as the company expands the number of stores participating in the program. Best Buy beat Amazon in shipping speed in early 2014 thanks to its ship-from-store strategy, showing dramatic improvement as it expanded the initiative.

Is this a threat to Amazon?
Any major retailer making a serious attempt to increase online sales is a threat to Amazon. It doesn't really matter how many robots Amazon has in its warehouses when Wal-Mart can ship an order from a store that might be just a few miles away from the customer.

It also doesn't help that Amazon no longer offers the lowest prices online. A recent survey showed that both Wal-Mart and Target offered lower prices in major categories including apparel, electronics, and housewares. With both companies now willing to match the prices of their online foe, any pricing advantage Amazon once had appears to be gone.

Ship-from-store allows Wal-Mart, Target, and any other large retailer to get in the e-commerce game without having to match Amazon's heavy spending dollar-for-dollar. While Amazon has been the dominant online shopping center for many years, serious competition from traditional retailers has finally arrived.