HOUSTON — An Astros official confronted a Yankees employee operating a high-tech camera during their late-May series at Yankee Stadium, leveling a charge of cheating and threatening that the culprit would be barred from working in the major leagues for life.

The matter was quickly defused when the Yankees proved that the Commissioner’s Office already had given its blessing for use of the camera.

The Post learned of that May dust-up Wednesday, a day the Commissioner’s Office confirmed that — during this ALCS — it had investigated the presence of an Astros employee in the camera pit near the Red Sox dugout early in Game 1 at Fenway Park. That employee was removed, and the MLB investigation found the employee was monitoring the Red Sox to see if Boston was improperly using a video monitor.

Both incidents underscore the burgeoning role of technology in the game, the paranoia about how the technology is being used and the lengths to which teams will go to catch each other in the act of cheating.

In fact, on Wednesday, Astros GM Jeff Luhnow acknowledged he used the equivalent of a surveillance crew in each visiting stadium this season to “play defense” against the potential of other teams using nefarious means to cheat — namely using real-time technologies to steal signs.

Before the 2018 season, the Commissioner’s Office required all 30 teams to supply a list of every camera at its disposal that was taking video at or near its playing field. Teams have come to use high-tech cameras as teaching and player-development tools, but the growing concern was they were also being used for more nefarious acts such as sign stealing. So MLB asked to know the intent of each camera and whether it was live (could be used in real time to cheat) or recording.

During the season, the Yankees wanted to buy a camera that took thousands of frames per second. They wanted to use it to minutely capture hand grips as a teaching tool to show their pitchers ideal hand positioning to upgrade spin rate, movement, velocity, etc.

They asked MLB for its blessing before purchasing the camera and MLB gave approval, but cautioned that such cameras might be banned next year as part of a large review by the commissioner. So rather than mount the camera — as most other teams that have one do — the Yankees would have an employee shoot from the center-field black camera well area. It was a wide-open, non-obscured area — hence, not covert.

During an Astros-Yankees series May 28-30, Houston senior director of baseball operations Brandon Taubman went to that hitting-eye area, which would be off-limits to an employee of an opponent. Commissioner Rob Manfred issued a memo last year that anyone caught stealing signs would never work in baseball again, and this was relayed as a threat to the Yankee employee.

The Yankees recognized that someone operating a camera manually would have raised their suspicions, so they recognized the Astros concern. So, Yankees assistant GM Jean Afterman called MLB’s senior VP of operations, Peter Woodfork, to alert him of the incident and to remind that permission had been granted for the camera. Yankees GM Brian Cashman called his Astros counterpart, Luhnow, to also explain that this was a non-live feed camera designed for scouting purposes.

The Astros, with the information, decided not to make any charges with MLB, and the matter was dropped. The Yankees and MLB did not want to comment on this matter, and Taubman did not respond to an interview request about the incident.