Walmart Inc. (WMT), the world's largest retailer, is opening FedEx Corp. (FDX) shops for printing, packaging and shipping in 500 of its U.S. stores as it hedges against the rising dominance of e-commerce and cloud computing giant Inc. (AMZN). (See also: Walmart Cheated to Vie With Amazon: Former Exec.)

Over the next two years, FedEx Office locations will pop up within domestic Walmart stores in a move intended to lure customers away from Amazon and its growing number of perks such as its Prime members' free two-day shipping, 5% back on Whole Foods purchases and other special rewards and discounts.  

"We gravitated toward Walmart because they have this fantastic physical infrastructure," said FedEx Office Chief Executive Officer Brian Philips in an interview with CNBC. "We are already great partners with Walmart on the transportation side, so it was natural for us to talk about a store-within-a-store format."

At the ShopTalk conference in Las Vegas on Tuesday, the two companies touted the success of a pilot program that involved about 50 locations in North Carolina, South Carolina, Virginia, Arkansas, Texas and Colorado. The small-format FedEx Office shops will allow consumers to hold their packages in store for up to five business days, offering convenience for some customers based on where they live and easing worries about package thieves that have come to be known as "porch pirates." Shoppers will also be able to use the pint-sized FedEx locations to redirect packages and process retail returns.

Companies Tout Success of PTest

Philips added that test also saw success with salespeople using the locations inside Walmart to hold inventory. Given that shoppers typically look to spend at Walmart after visiting FedEx, the alliance should also boost foot traffic in stores, according to the retail executive. 

On a broader scale, the move marks an ongoing race in the retail space to tackle "last mile" deliveries. Amazon recently began placing pickup lockers within Whole Foods stores and malls, and is reportedly considering buying up Toys R Us locations to decrease delivery times to some shoppers. Target Corp. (TGT) has doubled down on its supply chain strategy by buying transportation tech company Grand Junction and grocery delivery service startup Shipt. 

As for FedEx, which saw its stock plummet last month on fears of Amazon's competing Shipping With Amazon service, the deal is one of many in which the carrier has recently expanded its retail presence in the U.S., with pick-up and drop-off locations at retailers including Office Depot Inc. (ODP), Walgreens Boots Alliance Inc. (WBA), Kroger Co. (KR) and Albertson's. (See also: Food Wars: How Walmart Plans to Beat Amazon.)