Over the past decade, aftermarket auto parts retailers enjoyed phenomenal success from industry trends that favored their businesses. Even so, the rewards weren't equally bestowed, with some like AutoZone (AZO 0.96%) wildly succeeding and some such as Pep Boys stumbling hard.

Most of the other major players largely fell somewhere in between those extremes. Looking at how the markets responded, we can see two clear winners emerge: AutoZone and O'Reilly Automotive (ORLY 0.49%).

AZO Chart

AZO data by YCharts.

That's not happenstance, either. There are some very good reasons why, when comparing AutoZone and O'Reilly to competitors Advance Auto Parts (AAP 3.41%) and Genuine Parts (GPC -0.33%), the former two excel.

The aftermarket auto parts market is primarily comprised of two components: people who want to fix their own cars themselves (the do-it-yourselfers) and those who want someone else to do the work (or the do-it-for-mes).

Both AutoZone and O'Reilly cater to the DIY portion of the market, though to varying degrees.

AutoZone is the king of the DIY retailers, operating more than 5,600 retail stores in the U.S., Puerto Rico, Mexico, and Brazil selling automotive replacement parts and accessories for cars, SUVs, vans, and light trucks. While it has a commercial business that distributes parts to garages, dealers, and service stations who cater to DIFMs, AutoZone generates no money from repairing vehicles itself.

O'Reilly Automotive also serves both the DIY and DIFM markets, and like AutoZone, it has no repair shops. Instead, it operates 4,523 stores in 43 states and supplies those shops that do repair services. But where O'Reilly skews slightly in favor of DIYers, generating 58% of its revenue from that market, AutoZone realizes some 82% of its revenue from them.

In comparison, Advance Auto Parts falls the other way, getting 57% of its revenue from DIFMers, just like Pep Boys, which obtains about 56% of its revenue from the segment. That both of those aftermarket auto parts companies have lagged the industry is not surprising.

Although hedge fund Starboard Value views the DIFM market as having the best growth potential because of the growing complexity of cars making it more difficult for people to do their own repairs, the sagging economy and dour prospects for the future suggest people will continue trying to fix their own vehicles while they can.

AutoZone's heavy exposure to the DIY segment has translated into industry-leading market share. Although the marketplace is highly fragmented when including car dealerships, independent auto parts stores, and the like, one company rises to the top.

Although Advance Auto Parts has an equal slice of the pie, because it skews to the DIFM side of the equation, its prospects don't shine as brightly as AutoZone's. 

Data source: Chart by author from data provided by Starboard Value from Morgan Stanley

And if you look at which company's stock valuation is most attractive compared to its earnings, AutoZone is again favorably positioned.

AZO P/E Ratio (TTM) Chart

AZO P/E Ratio (TTM) data by YCharts.

Although it's true that an economic downturn could make it difficult on the aftermarket auto parts industry as customers could be put in financial straits that make auto repair take a backseat to other priorities, it's also a fact that cars are essential, particularly in a downturn, to get and keep jobs.

The industry has proven remarkably resilient in good times and bad, and Starboard Value notes there have only been three quarters in the past decade where one of the players reported declining same-store sales. Generally, business is always going up, and that should give investors encouragement that AutoZone will remain the leading aftermarket auto parts retailer.