Amazon has crushed many iconic American companies, but auto parts retailers like O'Reilly and AutoZone have managed to fend them off.

For now.

Stores that sell car batteries, mufflers and other parts are facing new pressure since Amazon started selling auto parts. Big retailers like Walmart have also jumped into the fray, in part, to compete against Amazon.

So far, auto parts retailers have been spared from sharing the same fate as Barnes & Noble, Toys R Us and so many other companies rendered redundant by Amazon.

For years, the $130 billion business selling aftermarket auto parts was one of the steadiest segments in retail, with mild cyclical fluctuations and slow trend of consolidation, MoffettNathanson analyst Greg Melich told CNBC. The segment even managed to make it through the recession reasonably well, as drivers repaired instead of upgrading their cars.

But pair of warm winters and a variety of other factors in 2016 and 2017 took a toll on the segment, just as Amazon and Walmart stepped up their efforts to grab market share. Now there is an oversupply of sellers in a market that has been experiencing slower demand, and may see slower growth in the next few years, Melich said.

"The battle of the titans between Walmart and Amazon is only just starting," Melich said. "The smart companies are doing what they should do, which is lean into the more service oriented part of the business on the commercial side."

Amazon pulls in about $6 billion in annual sales from "do-it-yourself" auto parts customers and is partnering with Sears to sell tires.

Walmart has also stepped up its game in the segment over the last three years, even at the expense of profit margins, Melich said.

In 2018, MoffettNathanson expects Amazon and Walmart to have a combined share of about 23 percent of the "do-it-yourself" market — with Amazon at about 8 percent and Walmart around 15 percent. Just 5 years ago, the two retailers had up to 17 percent of that market.

The more a retailer serves consumers, the tougher it will be for them to compete against Amazon.

About 80 percent of AutoZone's business comes from people repairing their own cars with the other 20 percent coming from professional mechanics. About 60 percent of O'Reilly's sales comes from the do-it-yourself consumer market with mechanics making up the rest.

The split is reversed at Advance Auto Parts with 40 percent of its revenue coming from consumers. Just 25 percent of the sales at Genuine Parts, which owns NAPA, comes from people popping their own hoods to fix that troublesome rattle.

"Amazon is obviously more of a risk to an AutoZone which does a majority of their business in DIY," Jordan said. He added that AutoZone is making a big push into serving commercial customers where there's more potential growth.

The increasing technical complexity of cars means it is ever more difficult for ordinary customers to service what they own.

That bodes well for sales of parts on the commercial side. More sophisticated parts cost more money. A halogen headlight for a 2005 Jeep Wrangler might cost $15, but a new headlamp on a luxury vehicle — the sort that can swivel to follow the shape of the road — might cost hundreds of dollars, Jordan said.

So far, Amazon has not been able to crack the code of the commercial auto parts business. Parts sellers need a mind-boggling degree of inventory — enough parts for the wide array of cars on the road, Jordan said.

It also does not yet have enough points of distribution around the country to replicate what auto parts stores do for commercial customers, and it might not be the best use of their resources right now to invest in that, Melich said.

Of course, he added, that could change in just a few years. Amazon didn't have a strong grocery distribution network, that is, until it bought Wholefoods Market.