But Northampton had to come from behind to record their second win against Bournemouth this season, having beaten them earlier in the league, after Danny Hollands gave the visitors a 33rd-minute lead when keeper Chris Dunn and Chris McCready got in each other’s way.
Apart from the goal, neither side created too much in the way of chances in the first half.
But Northampton got back on level terms in the 66th minute when Steve Guinan headed home Gilligan’s free-kick.
Two minutes later Courtney Herbert should have put Northampton ahead after racing clear but he shot wide.
In a pulsating finish Bournemouth had a chance to win from the penalty spot in the 88th minute following a handball by McCready but Dunn saved Lee Bradbury’s penalty.
And two minutes into stoppage time Herbert won a penalty for Northampton and Gilligan converted the ensuring spot-kick to book his side’s place in the next round of the Johnstone’s Paint Trophy.