"Wal-Mart was the great destroyer of retail, the great disruptor, laying waste to mom and pop stores all over the country by offering more products and undercutting them on price," Cramer explained.

Before the rise of Amazon, Wal-Mart's scale and massive array of merchandise shuttered countless smaller stores because they could not compete.

"You might think this comparison sounds crazy, even after the excellent quarter Wal-Mart just reported [on Thursday], but when you take a step back, it's pretty clear that these two companies have a lot more in common than you might expect," the "Mad Money" host said.

For so long, it seemed like no company could rival e-commerce colossus Amazon , but Jim Cramer thinks one up-and-coming online competitor could give it a run for its money: Wal-Mart .

Amazon employs a similar strategy, using its scale to sell items online at their lowest available prices. Most retailers cannot compete, but Wal-Mart's breadth and ability to negotiate with its suppliers enable it to keep pace with Amazon's prices.

Wal-Mart CEO Doug McMillon also set a goal for the company to become a major player in online retail, gaining approval from the Walton family, which owns just over half of the business.

With a good balance sheet, the company can afford to spend the money to challenge Amazon, but Cramer said the family's approval was key for moving the process forward.

"As long as he's got the backing of the family, he can afford to take some short-term hits in order to grow the company's e-commerce presence. That's a real rarity in this game," Cramer said. "At most publicly traded companies, the shareholders tend to rebel when management starts promising near-term pain. And you better believe that declaring war on Amazon is painful."

While Wal-Mart may not unseat Amazon as the top dog in e-commerce, the "Mad Money" host does believe it could become a serious competitor, with its online sales business up 63 percent in the latest quarter.

On Wal-Mart's earnings conference call, the company touted its offering of 50 million products, up from 35 million last quarter and 10 million just one year ago.

Wal-Mart's come-up in the online space started when the retailer announced plans to restructure in early 2015. The first step was closing 269 underperforming stores. Then, later in the year, McMillon announced a big boost in e-commerce spending — $900 milion in 2015 and $1.1 billion for the following year.

In response, the stock got pummeled, dropping from the mid-$80s to the mid-$50s, but with the backing of the Walton family, McMillon had permission to continue his agenda.

In the summer of 2016, Wal-Mart acquired one of the world's fastest growing online retailers, Jet.com, for $3.3 billion.

"The idea behind Jet is that they can offer customers tremendous bargains by giving you extra discounts if you order merchandise from the same distribution centers. Plus, the deal gave Wal-Mart access to a new cohort of wealthy, young, urban shoppers who might not otherwise be Wal-Mart shoppers," Cramer said.

After a number of smaller acquisitions that expanded Wal-Mart's online offerings, the company announced in March 2017 it would start its own incubator to invest in ideas and technologies that would change the future of retail, a new venture for the once-traditional company.

Finally, there's one area where Wal-Mart does have a leg up over Amazon: fresh food. Ordering most things online is easy, but delivering perishables is more complicated.

"Wal-Mart's grocery business is going strong, and once they get you in the door to buy that food, you might make impulse purchases — or if you know you're going there, you can order stuff online, then pick it up in the store [to] save on shipping," Cramer said. "Fresh food is Amazon's Achilles heel, people."

At the end of the day, Amazon is still the reigning king of e-commerce, but with 69 percent growth in online gross merchandise volume, Wal-Mart is easily second-best.

"Can Wal-Mart beat Amazon? Doubtful. But who says they need to? They just need to go toe-to-toe with Amazon and make money doing it, wipe out everybody else in bricks-and-mortar, and that's entirely likely from what I've seen from this amazing quarter," the "Mad Money" host said.

The stocks are completely different animals, however. Amazon's powerful technology and web services arm puts its stock, which trades at 85 times next year's earnings estimates, in a class above the rest.

Wal-Mart's stock, a more old-school brick-and-mortar name, sells at only 17 times next year's earnings.

"Here's the bottom line: if you like owning high-flying fast growing tech stocks, Amazon's great. OK? It's for you. However, if you want more of a value play, I think Wal-Mart has done an incredible job of expanding online. They're not going to take the lead in e-commerce anytime soon, but for the first time in ages, this business is actually a two-horse race," Cramer said.

Questions for Cramer?

Call Cramer: 1-800-743-CNBC

Want to take a deep dive into Cramer's world? Hit him up!

Mad Money Twitter - Jim Cramer Twitter - Facebook - Instagram - Vine

Questions, comments, suggestions for the "Mad Money" website? madcap@cnbc.com