Fashion and retail are notoriously hard businesses to gain a stable competitive advantage in, but Nike (NKE -0.18%) has managed to do just that over the past three decades. Since the mid-'80s, Nike has wildly outperformed the S&P 500 on its way to becoming a iconic global brand.

NKE Total Return Price Chart

NKE Total Return Price data by YCharts.

But success comes with a target ,and other athletic companies are gunning for Nike's growth. Under Armour (UAA 1.03%), Oakley, Puma, Adidas, and other brands are trying to play where Nike dominates. Here's how Nike has gotten ahead of the competition, as well as a look at how it can stay ahead.

Staying a step ahead in technology
Athletic gear isn't just about fashion; it's about technology as well. Under Armour made a splash in athletic wear when it launched with its compression fabric, and Nike was forced to respond or lose the market. The competition led to the Dri-Fit line that's come to dominate everything from cold-weather gear to golf polos for Nike.

Technology is even key to staying competitive in a sport like golf. Year after year, golf manufacturers fight to stay a step ahead of the competition with minor tweaks that improve performance. Nike has the R&D team to keep up, and with names such as Tiger Woods and Rory McIlroy at the top of Nike golf, the company is set up for success.

The next step of Nike's technology strategy is NikeFuel, a number generated through Nike FuelBands that tracks movement and calories burned. Now Nike is connected to its customers daily through the bands and electronically through tracking apps. Nike isn't just athletic wear; it's trying to become an athletic lifestyle through technology.

Growing up with the generations
Nike has managed to stay relevant among multiple generations as well, something that very few companies can do. In the youth market it competes against Under Armour in football, track, and other sports. Among adults it's a huge player in golf, competing against Callaway, Titleist, and Oakley.

A strategy that includes so many different sports and age ranges usually leads to disaster for a brand. What 16-year-old kids want to wear the same brand as their parents do? Somehow, Nike has managed to balance being "cool" with kids and being stylish with adults without alienating either. If Nike is going to stay a top stock, this will be key going forward.

Untapped markets
Finally, for Nike stock to continue outperforming, the market the company will have to continue expanding its presence. Before Tiger Woods, the company had almost no presence in golf, and today it's a major player. A market that Nike has left virtually untapped is the yoga market. lululemon athletica (LULU 0.80%) has a virtual monopoly on yoga, which provides an incredible opportunity for competitors.

A snafu in Lululemon's supply chain earlier this year may have supplied just the opportunity Nike and others needed. A batch of errant "see-through" pants has left stores out of stock in some of the most desirable fashions the company offers.

This is one area where Nike can actually compete on cost, offering yoga pants for a lower price than Lululemon. That's not usually a selling point for Nike, but it might be in this case.

Nike stock has upside
If Nike can execute on the keys I've highlighted, I think the stock has plenty of upside. Nike has been growing at high single or low double digits over the past three years, and that trend should continue as emerging markets spend more on athletic gear and Nike expands its product line.

From a margin standpoint, Nike is actually lagging behind both Under Armour and Lululemon, but that means there's either an opportunity to improve margins or to undercut these companies on cost (like in yoga).

NKE Gross Profit Margin Quarterly Chart

NKE Gross Profit Margin Quarterly data by YCharts.

Nike stock trades at 25 times earnings, which is a reasonable price given the upside potential I've highlighted. I'm confident enough in the company's future to make an outperform call on MyCAPS. Follow this and the rest of my picks here.