It was the highest ever successful run chase for the hosts against Surrey in first class cricket.
Keogh looked assured and untroubled until he fell agonisingly short of a well-deserved century shortly after lunch.
Luke Procter, who hit a gutsy half-century, then combined with skipper Adam Rossington to bring the runs required down below 50.
The pair were parted when Surrey took the new ball however and it was left to all-rounder Tom Taylor and debutant James Sales to hold their nerve and see Northants to the brink of victory.
Taylor fell with two runs required before teenager Sales hit the winning boundary, ending his first-class debut in style.
A hostile Jordan Clark toiled hard on a flat surface taking five wickets to keep Surrey in the hunt but ultimately Northants were able to earn a famous victory.
The County had needed another 214 at start of play while Surrey needed to take eight more wickets on a pitch that was becoming more docile.
Surrey’s seamers kept things tight early on, although it was a delivery from Clark which pitched outside leg stump which accounted for Emilio Gay who was unfortunate to be adjudged lbw for 50.
Keogh though continued to play confidently both in attack and defence, driving and cutting with exemplary timing.
He shared an 83-run stand with Procter who played the junior partner role at first but began to free his arms against the spinners, sweeping Amar Virdi over square leg and dispatching Cameron Steel through midwicket for another boundary.
Clark struck soon after lunch when Keogh clipped Clark straight to deep square leg to leave Northants on 205 for four with 115 still required.
Scoring started to dry up with Steel creating problems with flight and turn. Rossington though looked to be aggressive, using his feet to drive Steel through mid-on for four before swotting him over midwicket for six.
Procter capitalised on the new ball by punching Topley through cover for four before upper cutting him for another boundary to move to a gutsy half-century from 152 balls.
After a stand of 66 though, Procter and Rossington both fell to Topley and Clark respectively with the score on 271, with still 48 required with four wickets in hand.
Straight after tea Topley had Saif Zaib caught behind but Taylor and Sales absorbed the pressure and started to tick off the runs required.
Sales swayed out of the way of a short ball from Clark which flew away for four leg byes before Taylor hammered Topley through midwicket for four and struck Clark for a huge six in the same direction to bring the target down into single figures.
And then, despite Taylor's late dismissal, the County managed to record an excellent victory on the day head coach David Ripley announced he is standing down from the role at the end of the season.