Northamptonshire 479 (Rickelton 95, Procter 78, Sales 71, Young 61, Gohar 5-134) and 205 for 8 (Rickelton 68, Gohar 5-62) beat Gloucestershire 317 (Bracey 79, Dent 54, Higgins 50) and 363 for 9 declared (van Buuren 127*, Harris 62, Taylor 5-49)
Ryan Rickelton produced his second sparkling innings of the game to lead Northamptonshire to an exciting two-wicket wicket LV= Insurance County Championship win over Gloucestershire at Cheltenham.
The South African Test player smacked 68 off 47 deliveries, with three sixes and eight fours, as his side chased down a target of 202 from a minimum of 37 overs with 20 balls to spare.
Will Young contributed a rapid 43 to a total of 205 for eight as, despite Zafar Gohar's 5 for 62 and ten wickets in the match, Gloucestershire slipped to their eighth Championship defeat of the season.
Earlier, their skipper Graeme van Buuren had finished unbeaten on 127, from 187 balls, with 22 fours, to help his team extend their second innings from an overnight 135 for 5 to 363 for 9 declared. Tom Taylor claimed 5 for 49.
The declaration set up an exciting finish in fading light from which Northants emerged victorious to take 23 points to Gloucestershire's five.
The home side batted from the start of the day with an application notably absent from the latter stages of their first innings.
It was van Buuren who set the tone, defending solidly against accurate deliveries, while being merciless on anything short.
Ryan Higgins offered staunch support as the pair added 53 to the overnight score before falling for 17 to a brilliant one-handed slip catch by Young, diving low to his left, off Taylor.
The wicket did nothing to stem van Buuren's growing momentum and he went to fifty with three successive fours off Rob Keogh, having faced 87 balls.
Simon Kerrigan beat the outside edge on several occasions, but he and Keogh did not get the extravagant turn Gloucestershire must have feared on the dry final day wicket.
Zafar was typically positive, hitting successive fours when off-spinner Keogh switched to the Chapel End and cutting James Sales for six over point.
By lunch, he and van Buuren had added 58 and Gloucestershire led by 85. A further 25 were added before Zafar, on 38, edged the second new ball through to wicketkeeper Lewis McManus, Jack White being the successful bowler.
With Gloucestershire 273 for 7, Young dropped Tom Price at second slip off Ben Sanderson before he had scored.
Price went on to contribute a stylish 39 to a stand of 86 with van Buuren, who brought up his first hundred since taking on the Gloucestershire captaincy at the start of the season with a pulled four off Sanderson. He had faced 155 balls.
Taylor grabbed his fourth and fifth wickets with successive balls as Price and Zak Chappell skied catches into the off side and the declaration soon followed, tea being taken between innings.
Despite losing Emilio Gay, caught behind off David Payne, with only nine on the board, Northants were soon breezing towards their target as Rickelton, fresh from 95 in the first innings, and Young went on the attack.
By the end of the tenth over, they had taken the score to 68 and Rickelton then smashed two sixes in an over off Zafar to go to a sparkling half-century off 38 balls.
The century stand occupied just 69 deliveries, but then Rickelton fell lbw to a full ball from Zak Chappell and it was 132 for 3 when Young was stumped advancing down the pitch to Zahar.
With the light closing in, Zafar had Keogh stumped sweeping and pinned Luke Procter lbw in a spell from the Chapel End that saw him extract turn and lift.
But McManus (30) and James Sales (17) made sure of a Northants victory with a stand of 47. Both departed to Zafar at the death and Jack White was caught trying to make the winning hit, but by then team-mates were celebrating and Kerrigan duly hit the winning boundary.
"What an incredible game of cricket," John Sadler, Northants' coach, said. "All credit to Gloucestershire, who could have settled for a draw, but set up a great finish. I thought van Buuren's century on a turning pitch was a fantastic effort.
"We were always intent on going for the runs. Will Young and Ryan Rickelton showed they are world-class and how cool were Lewis McManus and young James Sales at the end? At times we looked in total control and at others we were under pressure. But we hung in there and got the result at the end of a fantastic day."
Van Buuren said: "I am so proud of my team. We have put in a tremendous amount of effort over four days in a game that was a fantastic advert for cricket and the County Championship First Division.
"It has been a lean season for me, so I was delighted to get some runs for the team. I don't think there is anything I would have done differently. One or two key moments didn't go our way.
"Zafar Gohar is a class act. The light was an issue at the end, but both teams wanted to stay out there and all credit to the players and umpires for completing a wonderful match."