After years of steadily posting strong sales growth, Costco Wholesale (COST -0.18%) fell into a sales rut in early 2016. This sales slowdown persisted for more than a year. For example, in the first half of fiscal 2017, Costco's comparable sales increased just 2% year over year.

Costco stock initially declined as sales growth slowed. However, it rebounded beginning last fall, largely due to a broad stock market rally and a membership-fee increase that should boost profits.

More recently, Costco stock has given back most of its gains from the past year, as investors have started worrying about the threat from's (AMZN -0.18%) pending purchase of Whole Foods (WFM). Nevertheless, with sales growth accelerating at Costco, this pullback represents a great buying opportunity.

COST Chart

Costco Wholesale Corporation stock performance. Data by YCharts.

Sales growth is back to normal

Much of Costco's sales pressure during 2016 was driven by deflation, with lower prices for goods offsetting increases in the quantity of items customers were purchasing. The company also made a strategic decision last year to stop selling tobacco products at many of its warehouses. This has weighed on its comp sales results for most of the past year.

However, these sales headwinds have now receded. (In fact, tobacco comp sales turned positive during June, according to the company.) Companywide comp sales growth rebounded to 5% in March, excluding the impact of fuel-price and currency fluctuations. On this basis, comp sales growth receded to 3% in April -- entirely due to the timing of Easter -- before reaching 4.5% in May and a stellar 6.5% in June.

With several months of strong sales growth in the books, it's clear that this acceleration in Costco's comp sales performance is a trend rather than a fluke.

Profit growth is improving

The uptick in sales growth at Costco will help the company leverage its fixed costs, improving its profit margin. This should allow Costco to build on the strong profit growth it reported last quarter, which was driven in large part by the benefits of its new credit card partnership with Citigroup.

The entrance to a Costco Wholesale warehouse

Sales and profit growth are accelerating at Costco. Image source: Costco Wholesale.

Looking ahead, membership-fee growth could further boost Costco's EPS growth in the next year or so. Costco is already starting to profit from a membership-fee increase that it implemented in many international markets last fall. By fiscal 2018, it will reap the full benefit of that increase.

More important, Costco raised its membership fees in the U.S. and Canada (its two largest markets) effective June 1. By the time this increase fully kicks in next year, it will boost Costco's operating profit by more than $250 million on an annualized basis.

The combination of rising membership fees and improved sales productivity in its stores should allow Costco to post strong double-digit profit growth next year.

The threat is overblown

Despite this favorable outlook, investors have lost interest in Costco stock recently. The culprit was Amazon's recent announcement that it plans to buy Whole Foods. Many investors suspect that Amazon will cut costs and reduce prices at Whole Foods, using the latter's retail footprint to gain market share in the grocery business.

While there's a good chance that Amazon will follow this strategy -- or something like it -- price cuts at Whole Foods will impact supermarket chains much more than they will Costco. First, with annual revenue approaching $130 billion, Costco has massive purchasing power. Second, Costco's markups are extremely low thanks to its super-efficient business model. As a result, nobody can beat Costco's prices on a consistent basis.

Under Amazon's guidance, Whole Foods may be able to cut prices to become competitive with traditional supermarket chains on price. However, it's extremely unlikely that it will be able to match (let alone undercut) Costco on pricing.

Between its industry-leading cost structure and its loyal membership base, Costco Wholesale should be able to thrive regardless of what Amazon does in the future. With the stock now trading for a relatively reasonable 25 times forward earnings, this could be a great time for investors to snap up some shares of this long-term winner.