Two years ago, when AutoZone (NYSE:AZO) was trading at $84, we recommended it in our Motley Fool Inside Value investing service.

The stock bounced around a bit, then entered a steady uptrend that took the shares above $135. At that point, we recommended a sell, for a total return of about 60%.

That's a solid two-year return, roughly doubling the performance of the S&P 500. But rather than just basking in the glow of a successful investment, it's worthwhile understanding why it was successful, so that you can use the same strategies to identify other excellent stocks.

I see four main reasons why AutoZone was such an outstanding investment.

1. A dominant position
AutoZone is an auto parts retailer that primarily sells to amateur mechanics who want to fix their own vehicles rather than hiring an expensive mechanic. It's not an easy business -- there is significant competition from Advance Auto Parts (NYSE:AAP), Genuine Parts (NYSE:GPC), Pep Boys (NYSE:PBY), O'Reilly Automotive (NASDAQ:ORLY), and even Wal-Mart (NYSE:WMT).

Yet, despite the relatively crowded space, AutoZone holds its own. It's the biggest of the pure parts retailers, with nearly 3,800 stores. Thus, the company has significant economies of scale, with both an excellent distribution system and a wide selection of parts. Against bigger but less-specialized competitors like Wal-Mart, AutoZone has the advantage of more knowledgeable staff.

AutoZone's superior position shines through in the numbers. It has the highest sales per square foot, highest return on invested capital, and highest profit margins of any company in its niche.

2. Solid financials
While AutoZone had about $1.9 billion in debt back in 2005, that wasn't an excessive amount considering that the company was earning more than half a billion dollars a year. What's more, AutoZone only needs minor capital expenditures to maintain its stores, so it has high free cash flow. There would have to be a major catastrophe before AutoZone's balance sheet became an issue.

3. A cheap price
Even if you can identify an excellent business, you'll often find that the stock is priced for excellence as well. But in 2005, AutoZone wasn't. In fact, it was cheap.

Its CEO had left to join Office Depot (NYSE:ODP) and AutoZone's same-store-sales growth was poor. But the market was so gloomy that it completely failed to recognize the positives. This gave us the opportunity to buy a great company at about 75% of what it was actually worth. At such a discount, the stock offered both a margin of safety and a substantial upside.

4. Growth potential
At the time, we estimated that AutoZone could grow earnings per share at a rate of about 9% to 12% annually. We could see this growth coming from AutoZone optimizing its inventory management, leveraging its existing infrastructure to open new stores, improving same-store sales, and entering adjacent markets like commercial sales.

What's more, the company was quite willing to use its free cash flow to repurchase shares at these undervalued prices. In fact, in the prior seven years, the company had repurchased half its outstanding shares. So, the company had several attractive opportunities to grow its earnings per share.

Why we made 60%
Typically, we'd expect undervalued stocks to increase in price and return to fair value. In this case, because we thought AutoZone was trading at about 75% of fair value, the upside was about 33%. But over the course of the two years, the company grew its earnings by 8% a year -- not quite at our target, but still a decent amount. Thus, the intrinsic value of the stock increased as well. So, when the stock returned to fair value, we ended up with a nice 60% gain.

With so many positives, why did we recommend a sell? Well, we still think AutoZone is a rock-solid company that is likely to maintain its dominant position. But its top-line growth has been uninspiring and, at this point, it's trading north of our estimates of its fair value. It's not a bad stock, but at these prices, we simply see better places to invest.

There are many companies out there right now with similar characteristics to AutoZone -- businesses with strong competitive positions, reasonable growth, and solid financials, trading way below their fair value. It's from among these stocks that we'll find the next AutoZone. If you're interested in seeing what I'm talking about, you can check out Inside Value here with a free pass.

Fool contributor Richard Gibbons would fix his own car, but can't figure out how to fit the doohickey in the snazzlepump. He does not have a position in any of the stocks discussed in this article. Wal-Mart is an Inside Value recommendation. The Motley Fool has a disclosure policy.