McDonald's (MCD -0.42%) may be famous for selling affordable fast food, but its stock is by no means cheap right now. The shares are sitting near all-time highs even though major indexes are still below their late-2021 peaks.

But if one steps back a little, that market-thumping rally makes plenty of sense. Mickey D's is putting up fantastic growth metrics lately, and profit margins are expanding toward new records. So let's take a look at a few reasons why this stock is still a buy at the current elevated valuation.

Beating the industry

The restaurant and fast-food industry has had a good run lately as consumers shifted their spending toward more experiences and away from many of the product categories they had favored during the pandemic. Yet McDonald's results stand out even in this growing sector.

Sales in Q1 rose 13% in each of the company's geographic categories, including the U.S. Compare that to Chipotle Mexican Grill, which notched an 11% increase for the period. McDonald's achieved its success through a combination of higher customer traffic and increased average spending, too.

The boost was powered in part by improvements to basics like order time and customer satisfaction. "Running great restaurants is fundamental to our business momentum," CEO Chris Kempczinski said in a press release.

Standing out again

McDonald's also stands far above rivals in the financial department. Many investors might have believed the chain couldn't improve on its 40%-plus operating profit margin after the company finished its refranchising strategy. But the last year or so has demonstrated that McDonald's can set new records here.

MCD Operating Margin (TTM) Chart

MCD Operating Margin (TTM) data by YCharts

Profit margin is rising thanks to the combination of fast sales growth, higher prices, and slowing expense inflation. Investors also get a solid dividend that boosts these returns even further. Late last year, McDonald's raised its payout by 10% and the yield is currently sitting at just over 2%. That's only slightly lower than the dividend yield of Burger King owner Restaurant Brands International.

A fair price

As you might expect, investors are being asked to pay a premium for all of those competitive assets. McDonald's shares are priced at roughly 9 times annual sales compared to a price-to-sales ratio of 6 for Chipotle and 5 for Restaurant Brands International.

The higher price is worth paying, though. In addition to its excellent growth and profit metrics during boom times like the current expansion cycle, McDonald's stock can generate solid returns when consumers are pulling back their spending levels.

The chain has a proven ability to feature both premium products and those targeted at more value-conscious shoppers. Its huge sales footprint and high profit margins, meanwhile, protect shareholders from the type of sharp operating downturn that might hit smaller peers.

It's possible that McDonald's stock will become cheaper over the next few quarters, especially if the market declines. But investors don't have to wait for that potential slump. The fast-food giant has earned its premium and should deliver tasty returns for patient shareholders who buy the stock right now and hold for several years at least.