The FBI is probing the St. Louis Cardinals for hacking into the internal databases of ​longtime division rival Houston Astros to steal player information, sources told The Post on Tuesday.

Calling the sensational allegation a case of “industrial espionage,’’ a federal source said the bureau is investigating whether the scheme was part of a “retaliation’’ plot against former Cardinal​s​ ​executive Jeff Luhnow, who jumped ship to the Astros in 2011.

While with the Cardinals, Luhnow helped construct an internal computer network ​called “Redbird” ​for the team to house its baseball-operations information. The data included higher-ups’ discussions about trades, proprietary statistics and scouting reports.

Investigators believe that some members of the Cardinals organization feared that Luhnow took some of that proprietary data with him when he defected to Houston, the source said.

While probing the Cardinals’ alleged misconduct, the FBI also is looking into those charges against Luhnow, the source said.

It’s unclear how high up the alleged baseball Spygate goes on the Cardinals’ side.​ The probe was first reported by the New York Times on Tuesday.​

After the FBI probe was launched, “agents soon found that the Astros’ network had been entered from a computer at a home that some Cardinals officials had lived in,” the Times reported.

The Cards may have been able to gain access to the Astros’ network because Luhnow also constructed his new team’s player-data system after taking over as Houston’s general manager — and may have used at least one of the same passwords in both places.

The Astros were the ones to notify the FBI that they had been hacked, the source told The Post.

But it appears that the team only learned of the infiltration after some of their internal data was already published online by a hacking site in 2014, the Times said.

At the time, the leaked information included the Astros’ efforts to land pitcher Bud Norris and their balking at ​nabbing right fielder Giancarlo Staton, Deadspin reported.

Major League Baseball said in a statement that it “has been aware of and has fully cooperated with the federal investigation into the illegal breach of the Astros’ baseball operations database.”

The normally exemplary Cardinals team – which boasts the best record in baseball this season (42-21) – has reached the National League Championship Series nine times since 2000 and last won the World Series in 2011. The Cardinals’ 11 titles are second​​ only to the Yankees.

Both the Cardinals and the Astros are currently in first place in their divisions.

St. Louis’s rivalry with Houston is one of the best known in the MLB, with both teams going up against each other in the National League’s Central Division for nearly two decades. The Astros moved to the American League West in 2013.

There’s no doubt that when Luhnow left St. Louis for Houston, that rivalry grew more bitter.

After last year’s network breach, Luhnow admitted, “Today, I used a pencil and paper in all my conversations.’’

Additonal reporting by Yaron Steibuch