It looked like a goalless draw was going to be enough for Alloa to jump out of the relegation zone, with the Edinburgh club on the verge of wasting a chance to go nine points clear of Rangers at the summit.
In a relatively uneventful first period, Dale Carrick had the first meaningful effort on goal, the Hearts man coming close from just outside the box.
Alim Ozturk had a much easier chance to put the visitors in front on the half hour mark, his right-footed shot from close range somehow managing to clear the crossbar.
Alloa's Ben Gordon and Stephen Simmons both found their names being jotted down by referee Calum Murray, and Michael Doyle would join them shortly after the break as the second half began the way the first ended, with Alloa remaining vigilant in defence and not offering much at the other end of the field.
The breakthrough eventually came in the dying embers of the game when Liam Buchanan fouled on the edge of the Alloa area and gave Adam Eckersley the chance to step up and put the ball in the back of net, extending Hearts' lead over second-placed Rangers at the top of the league.