Aguirre had been warned by officials earlier in the game to stop imitating the whistle before being handed his marching orders deep into stoppage time with the referee stating in his report that the coach made whistle sounds "with the intention of confusing the players."
According to reports, on multiple occasions during the game a second whistle was heard, especially during set pieces, creating confusion among TV and radio commentators and players.
Leganes assistant coach Toni Amor, who was not aware as to why Aguirre had been sent off, said his team felt hard done by the referee's decision to award Messi the penalty after the Argentinian was adjudged to have been fouled by Jonathan Silva foul in the box.
"For me it's not a penalty," Amor said after the game.
"We are also fighting for our lives and any action is crucial. I believe that had it been the other way round, that penalty would not have been given."
Leganes are at the bottom of La Liga with 24 points, three points adrift of Celta Vigo, who occupy the last safety position and have a game in hand.
Aguirre is expected to serve a one-match touchline ban in Friday's game against fellow relegation strugglers Mallorca.