Costco Wholesale (COST 0.76%) and Amazon.com (AMZN 0.59%) are probably the two strongest mass-market retailers today.

Amazon has redefined the retail sector over the past generation by making e-commerce mainstream. With its Prime loyalty program, the company has made free two-day shipping, which recently became one-day shipping, the norm in the industry, and has forced brick-and-mortar retailers to play catch-up.

A set of scales with two stacks of coins on them

Image source: Getty Images.

However, Costco, the membership-based warehouse giant, has been largely unscathed by Amazon's onslaught in the industry and continues to put up steady growth in its niche of the retail industry. 

Over the past three years, the stocks' performance has been roughly the same, though Costco shares have come on strong lately to narrow the gap between them.

AMZN Chart

AMZN data by YCharts

Costco and Amazon's success stems from a number of commonalities. Both companies are known for customer satisfaction, low prices, and a membership model to keep customers locked in. Considering the two companies also dominate today's retail landscape, they're competing for investor dollars as well. Let's see where both stocks stand to determine which is the better buy today.

A parking lot in a Costco store

Image source: Costco.

A retailer on fire

With its membership, buy-in-bulk model, and rock-bottom prices, Costco is one of the few retailers to appear to be Amazon-proof, as it continues to draw growing numbers of customers to its stores. The warehouse retailer just wrapped up a fiscal year that included adjusted comparable sales growth of 6.1% globally, with comps up 6.4% in the United States. E-commerce sales increased 23% as the company makes inroads into online retail, with offers such as free two-day shipping on orders with a $75 minimum. 

Those gains on the top line drove earnings per share up 17% to $8.26 as the company benefited from both increasing membership and profits from its core business. In its fourth quarter, Costco's membership renewal rates reached an all-time high, both in North America at 90.9% and worldwide at 88.4%, showing that the business' appeal is as strong as ever.

Costco continues to add new stores in the U.S., with considerable "white space" for the company to expand, meaning sales will keep growing through increasing traffic at current stores, online sales, and new stores. And the company's first opening in China smashed expectations. Its Shanghai location has already signed up more than 200,000 members, which compares favorably with the company average of 68,000 members per location. 

Costco pays a modest dividend, with a current yield of 0.9%, but it also has a history of paying special dividends every two to three years, meaning one could be around the corner, though the company has been mum on the subject.

Overall, Costco looks as strong as ever, with ample room for growth in the U.S. and China, but the stock's valuation has risen, now trading at a P/E of 36, its highest price in over a decade.

An Amazon Prime Air jet

Image source: Amazon.com.

More than an e-commerce giant

While Costco shares are at an all-time high, Amazon stock has stalled over the past six months. Investors appear to be giving it a reality check after the company's valuation topped $1 trillion last year. In April, the tech giant said it would accelerate its standard two-day Prime delivery to one day, a move that will cost it billions of dollars this year and $1.5 billion in just the fourth quarter.

The decision to move to one-day delivery should pay off over the long term, since it will give the company an edge over rivals WalmartTarget, and Costco, which have made their own efforts to increase e-commerce speeds and offer convenient pickup options for online orders. However, Amazon's investments are causing profits to take a step back. Earnings per share fell in the third quarter, the first time profit has dipped in two years, following a surge in profit growth. The company also expects fourth-quarter profits to fall.

Meanwhile, its cloud-computing juggernaut, Amazon Web Services, is seeing profit growth slow amid increasing competition and investments. It also just lost a $10 billion pentagon contract to Microsoft, a sign that its status as the infrastructure-as-a-service leader is in jeopardy.

Amazon continues to be one of the most innovative companies in the world as it expands its cashier-less convenience-store chain, Amazon Go, and has just launched an in-house pilot of a new healthcare service called Amazon Care, adding credence to the company's ambitions to take over the massive healthcare industry. But with a valuation already near $1 trillion, the biggest question about Amazon stock is how much higher it can go.

Who's the winner?

Amazon and Costco will appeal to different investors. Amazon has long been a favorite among growth investors because of its record of rapid sales growth and its emphasis on innovation, but the stock has also been volatile because of the company's profit swings and its high valuation. Today, Amazon is worth about $880 billion and trades at a P/E near 80. That makes it difficult for the stock to achieve the kind of monster returns investors have gotten used to, since it would need to add hundreds of billions in market value to deliver market-beating growth. Without significant profit growth, which seems to have taken a pause, that seems unlikely.

Costco, on the other hand, may not have the potential to transform whole industries the way Amazon does, but its growth path is clear and reliable, it pays a dividend, and the stock is significantly cheaper than Amazon. While both stocks could easily merit a place in the average investor's portfolio, Costco looks safer and more reliable for the foreseeable future. For most types of investors, it's the overall better buy.