The Astros took a 5-4 lead into the ninth inning, with Minor League left-hander Chris Salamida sent out to close the game.
Instead, he gave up a leadoff single to Mitch Einertson and Esposito then lined Salamida's 0-1 pitch over the right-field fence to give the Hooks the victory.
The Astros trailed 3-2 entering the eighth inning before stringing together three runs to take the lead.
Reggie Abercrombie drew a leadoff walk, with Jason Smith following with a hit-and-run single to put runners on first and third.
Humberto Quintero then laced a single to right field to score Abercrombie. Hooks outfielder Mitch Einertson overran the ball, allowing Smith to score and Quintero to take third.
Lance Berkman followed with a soft single to left that scored Quintero for a 5-3 Astros lead.
The Hooks came within a run on Andrew Locke's leadoff homer in the eighth, before Esposito's homer gave them the win.
After six dominant innings, Astros starter Wandy Rodriguez left with a 2-0 lead.
However, the Hooks took the lead in the seventh before reliever Jose Capellan could record an out.
Jhon Florentino cracked a two-run homer to the right-center field berm to tie the score. Then after a Jimmy Van Ostrand single and Capellan wild pitch, Collin DeLome laced a single to right field to plate the go-ahead run.
Rodriguez had his way against the Minor Leaguers, striking out 11 while allowing only Wladimir Sutil's third-inning double. In his final three spring starts, Rodriguez allowed no runs over 16 innings while striking out 20.
After two scoreless innings, the Astros got on the board in the third thanks to Hooks starter Felipe Paulino's lack of control.
Darin Erstad and Michael Bourn laced one-out singles to left field. One out later with Ivan Rodriguez at bat, consecutive wild pitches by Paulino allowed Erstad to score.
In the fourth, Hunter Pence, a former Hooks standout, laced a two-out RBI double down the left-field line to score Miguel Tejada, who had doubled with one out.
Thursday's game marked only the second time a Major League team visited Corpus Christi. The first was on April 8, 1958, when the Indians beat the Giants 11-7.