Northamptonshire 261 (Duckett 112, Holden 92, Klein 6-80) and 289 for 7 dec (Wakely 112, Keogh 105*, Ackermann 3-45) beat Leicestershire 157 (Gleeson 3-33, Sanderson 3-36, Azharullah 3-52) and 391 (Ackermann 105, Cosgrove 76, Pillans 56, Gleeson 4-109, Kleinvedlt 3-65) by 2 runs

Northamptonshire plucked victory from the jaws of defeat against Leicestershire to win the pink-ball Specsavers County Championship match by just two runs at Wantage Road.

Colin Ackermann's 105 and Matt Pillans' late-order 56 were steering Leicestershire towards a record chase of 394.

Then Pillans, with only No. 11 Dieter Klein for company, received a ball from Rory Kleinveldt that bounced a little more and took the splice of the bat to point. Leicestershire old-boy Josh Cobb dived forward to take the catch and Northants pulled a win out of the fire - it was Northamptonshire's joint-second narrowest margin of victory.

A thrilling final day where Leicestershire resumed needing 350 more to win with ten wickets in hand swayed back and forth. At 299 for 5 Leicestershire were on course to get up, only for Richard Gleeson to take two wickets in two balls seven overs into the second new ball. But then Pillans, on-loan from Surrey, swatted a 41-ball fifty - for the first time in first-class cricket - to revive the visitors' hopes.

In need of another breakthrough, Gleeson delivered - drawing an edge from Ackermann to wicketkeeper Ben Duckett after an innings worthy of winning a game. When No. 10 Clint McKay also fell caught behind, to Kleinveldt, 26 were still needed.

But back came Leicestershire. Klein survived for 20 balls and escaped an edge behind the wicket that Duckett dropped diving to his right when seven were needed. He and Pillans nudged Leicestershire to within one hit. Gleeson bowled a maiden to Klein before Kleinveldt came up with the winning moment - a potentially pivotal one for Northants' hopes of promotion.

Northants' coach David Ripley said: "It's the year of the thriller - the fourth game from seven that's been very tight - and it feels pretty good. I thought the game had slipped away at the death, they were edging to victory and we were looking back to dropped catches or maybe batting extra time, lots of things were going through my head."

Leicestershire were heartbroken, denied a first win of the season. Ackermann's century gave them a sporting chance, a well-paced innings that steered his side from danger after both openers fell in the first seven overs of play. He faced 198 balls and struck 14 fours and a six, sharing stands of 127 with Mark Cosgrove, and 58 with both Ned Eckersley and Pillans.

Ackermann was the rock around which Leicestershire built their chase which was reduced to 117 needed with five wickets in hand in 32 overs after tea as Northants took the second new ball.

The target was brought down to 95 when Gleeson suddenly found a double breakthrough. First Lewis Hill drove at one that left him and edged to first slip. Next ball, a knee-high slower ball struck Rob Sayer and he was given out lbw to record a pair.

Ackermann edged the first ball he faced to the second new ball through third slip who had just been removed but responded to being beaten outside the off stump by Ben Sanderson by running down the wicket and lifting a six into the Spencer Pavilion over long-on and hoisting another boundary over extra-cover.

But he couldn't win the game on his own. Enter Pillans on his Leicestershire debut, whose first-innings 35 saved Leicestershire from a huge deficit. He uppercut Gleeson over backward point for six, pulled four more through midwicket off Sanderson and lifted the next ball over mid-off for another boundary. It looked like being a fairytale debut until Kleinveldt found a ball to snatch the dream away.

That it took until the death was of Northants' making. Six chances were shelled, one on the third evening and five on the final day. The biggest misses were of Cosgrove on 23 - a sitter to Alex Wakely at second slip that would have had Leicestershire three down after just over an hour's play - and Ackermann on 43 - a flying edge to first slip that Kleinveldt put down. Duckett's miss appeared to be one-drop-too-many but Northants had a Get Out of Jail card up their sleeves.