With the U.S. economy in 2022 and 2023 facing headwinds from inflation and higher interest rates, warehouse retailer Costco Wholesale (COST 1.01%) has gotten all sorts of attention. Its sales have been humming along at a healthy clip, but its net income growth in particular has been brisk. That bottom-line figure is essentially a simple measure of Costco's income from its annual membership fees, as it doesn't actually sell its merchandise for anything resembling a net profit.

All of that growth over the last few years has culminated in Costco's recently announced $15-per-share special one-time dividend payment. Congrats, dedicated Costco shareholders -- your long-term mindset is well-deserving of a bonus.

What's really amazing about Costco stock, though, is how thoroughly it has beaten its largest peers on a total-return basis (stock price gains plus reinvested dividends) over the last five years. By that metric, Costco has delivered returns of 260% to shareholders over that period. Competitors such as Target (TGT 0.18%) and Walmart (WMT -0.08%) lag far behind. Even mighty Amazon's (AMZN 3.43%) stock performance pales in comparison.

COST Total Return Level Chart

Data by YCharts.

As amazing as Costco has been, though, I'm in no hurry to chase the stock now. Instead, I'm betting on a big contrarian stock pick that's hiding in plain sight.

How is Amazon a contrarian stock pick?

How is a juggernaut like Amazon a contrarian stock pick (one that goes against the grain of what is popular at the moment)? Well, the e-commerce pioneer got clobbered as pandemic-driven lockdowns and social-distancing efforts ended. Online shopping went from boom times in 2020 and 2021 to pedestrian growth at best in 2022 and early 2023.

Amazon's core e-commerce segment has been showing signs of life again. Especially important, after booking operating losses in 2022 following a period of over-expansion early in the pandemic, it has finally worked its back to producing a small operating profit in 2023 after some right-sizing of its warehouses and logistics infrastructure.

Meanwhile, Costco has been a steady Eddie performer.

COST Net Income (TTM) Chart

Data by YCharts.

As a result, Amazon stock remains down nearly 20% from all-time highs in the final days of 2023 while Costco is trading near its peak.

Amazon built its empire, in part, with an obsessive focus on the customer experience. Nevertheless, the e-commerce-focused giant has a lot to learn from Costco's own obsession with its customers, and its staunch practice of relying solely on its membership fees to produce its profits. Its wholesale procurement, supply chain and logistics management, and bare-bones store experience have been the foundations of a model that has attracted an army of loyal shoppers.

In some ways, Amazon is building a similar model. It has its Amazon Prime membership program, and still to this day derives only minimal operating profits from actual e-commerce sales. But it's still largely in "experiment mode" with some other revenue outlets built atop this e-commerce core (advertising, third-party merchant services, etc.). Once it figures out the right balance between growing its shopper base and providing higher-profit ancillary services, it could become a profit-growth machine that fuels decades of strong returns for investors -- most likely with the help of stock buybacks, in Amazon's case, since it pays no dividends yet.

Will Costco stock underperform over the next five years?

Weird things happen during periods of economic stress, and especially consumer stress. If U.S. households enjoy a resurgence in purchasing power in the coming years, I'm not sure Costco's focus on a smaller selection of merchandise at wholesale prices will make it the best company to benefit from the rally. Plus, its premium valuation (46 times trailing 12-month earnings per share, and nearly 40 times Wall Street analysts' earnings expectations for next year) just can't be ignored.

By contrast, Amazon -- a faster-growing business with all sorts of profit leverage potential from e-commerce plus its cloud computing leadership, which is also maturing as the cloud industry grows up -- trades for not much more of a premium on a forward-looking basis. It currently trades for 44 times next year's earnings expectations, with upside if it continues to make progress on ramping up its profit margins.

Thus, I would argue that if you missed out on Costco's incredible outperformance in the retail space over the past several years, you should fight the temptation to chase those returns by buying in now. Instead, recognize that Amazon could be next. I continue to buy it for 2024 and beyond.