Wal-Mart (WMT -0.32%) has long been the undisputed leader in retail. However, nothing lasts forever. Competition from players such as Amazon (AMZN -1.11%) and Costco (COST -0.11%) has inflicted considerable damage on Wal-Mart in the last several years. In addition, its increased spending in areas such as salaries and benefits, and its growing investments in technology are hurting profit margins over the middle term.

On the other hand, the business is still producing tons of cash, and management is generously rewarding investors with big dividends and buybacks. Besides, Wal-Mart stock looks remarkably cheap when compared against other discount retailers such as Costco and Target (TGT 0.70%)

Is Wal-Mart stock a buying opportunity for investors or just a dinosaur on its way to extinction?

The winds of change are hurting Wal-Mart
With more than 11,500 stores worldwide, Wal-Mart is the biggest retailer on Earth, and the company has long capitalized on its massive scale advantages to sustain growth and protect the business from the competition. Its gargantuan size allows Wal-Mart to negotiate low prices and flexible payment conditions with suppliers; after all, for many of those suppliers, Wal-Mart is their most important customer.

However, the Internet has changed almost everything, and the retail industry is no exception. Amazon is simultaneously a major driver of and the biggest beneficiary from the e-commerce revolution. In 1995, the company was just an online bookstore that made only $511,000 in revenue; two decades later in 2015, it produced an impressive $107 billion in sales, with revenue growing by 20% annually in U.S. dollars, and by 26% in constant currency. 

Costco is another industry player that has been gaining ground against Wal-Mart over the last several years. It was a pioneer in the warehouse retail business model, under which customers pay a membership fee for the privilege of shopping at the company's stores. Costco makes most of its profits from those memberships, as opposed to sales margins, so the company can charge aggressively low prices. Over the last decade, Costco's sales growth has more than doubled that of Wal-Mart.

WMT Revenue (TTM) Chart

WMT Revenue (TTM) data by YCharts

Wal-Mart is not standing still, though. Management has been making a series of moves to accelerate growth and fend off the competition. Among them, it is restructuring its store base, raising wages to improve the quality of its service, and investing more money in key areas such as technology and e-commerce. These initiatives will hurt profits in the middle term, but management is doing the right thing by putting the long-term health of the business above quarterly earnings considerations.

Wal-Mart stock is on sale
When compared to the shares of other retailers in its segment such as Costco and Target, Wal-Mart's stock looks quite cheap in term of ratios such as price to earnings, price to sales, and dividend yield. Wal-Mart will probably report lackluster financial performance in the coming quarters, but the stock seems to be already priced accordingly.

CompanyP/EP/SDiv .Yield
Wal-Mart 14 0.44 3%
Costco 28 0.56 1%
Target 16 0.61 3%

Data Source: Yahoo Finance and SEC filings.

Besides, Wal-Mart has an impressive track-record of dividend growth. The company paid its first dividend in 1974, and it has increased dividend payments each and every year since then, through good and bad retail environments. What was an annual dividend of $0.05 in 1974 has now grown into a $1.96 per year payout. The dividend payout ratio is around 43% of earnings expectations for the year ending in January 2016, so the company has plenty of financial room to continue raising dividends in the future.

In addition, management has recently announced a new share buyback program for $20 billion over the next three years. This is a lot of money, even for a company as big as Wal-Mart, since it represents nearly 9% of its market capitalization.

It's hard to predict what kind of financial performance Wal-Mart will deliver in the coming quarters, but management seems to be leading the company in the right direction, and the stock is remarkably cheap now. While investors are waiting for sales and earnings to accelerate again, they are being rewarded for their patience with big dividends and stock buybacks.