Shares of Lowe's surged more than 10% after the company posted better-expected results in its second quarter raised guidnace on Wednesday.

That's not the only thing that propped the stock's rally during the session, if you ask CNBC's Jim Cramer.

After Home Depot — Lowe's chief rival — beat profit estimations the day prior, a number of hedge fund managers loaded up on the equity and decided to short Lowe's, he said. A short is when an investor places a bet that a stock price will fall in the near future and tries to turn a profit on the depreciation.

"This kind of trade is a way to bet on the comparative performance of companies in a given industry," the "Mad Money" host said, calling it a "pairs trade."

When Lowe's reported this morning, however, they realized played their hands wrong. The home improvement retailer saw slightly higher same-store sales growth in the U.S. than Home Depot — 3.2% to 3.1%. The pairs trade was busted and caused a short squeeze, Cramer said.

"Traders know that discipline trumps conviction, that's a rule. If a trade goes against you, you have to get out, which in this case means covering your short positions at any price," he said. "Disciplined short-sellers bought back stock to close out their positions and take the loss, and it catapulted the thing into the stratosphere."

Cramer gives more insight into short squeezes here