Derbyshire 239 and 365 for 7 (Hudson-Prentice 91*, Godleman 86) beat Nottinghamshire 324 (Hameed 68, Patel 63, Nash 59) and 279 (Patel 80, Hameed 52) by three wickets
Fynn Hudson-Prentice showed skill and character under pressure to guide Derbyshire to a remarkable three-wicket victory over Nottinghamshire in the Bob Willis Trophy North Group match at Trent Bridge.
The all-rounder made a superbly judged unbeaten 91 from 169 balls as Derbyshire chased down a 365 target with one ball to spare to record their highest-ever successful run-chase against a county side.
The defeat means Nottinghamshire, who lost fast bowler Joey Evison with a foot injury early on the final day, have not won a first-class game since June 2018.
They were favourites to end that barren run when Derbyshire slipped to 234 for 6 but Hudson-Prentice shared half-century stands with Mattie McKiernan and Michael Cohen, on his 22nd birthday, to give a game of changing fortunes one final twist.
Both teams went into the final morning with expectations of victory although overcast skies suggested conditions favoured the bowlers. It was gloomy enough for the floodlights to be switched on and Godleman and Madsen had to fight for every run against disciplined pace bowling.
Godleman drove Evison to the cover boundary to bring up the century stand just before a short rain delay and when play resumed, the young fast bowler trapped Derbyshire's captain lbw with a full length ball that he played slightly across.
It was his last contribution as he left the field in the same over but despite being a bowler down, Nottinghamshire chipped away and claimed another big wicket before lunch.
Leus du Plooy scored a brilliant century in the first innings but this time he moved across his stumps to Steven Mullaney who swung the ball back in to have him lbw for 7.
Derbyshire's hopes now seemingly rested with Madsen who was so intent on survival he scored only 15 runs in the first session and his obdurate innings ended soon after lunch.
Madsen had faced 174 balls for 43 but Ball defeated him with a full delivery that caught him in front on the crease and Harvey Hosein had his stumps scattered four overs later.
But Critchley reined in his natural attacking instincts and with Hudson-Prentice, dug in to frustrate Notts for 19 overs. The pair added 42 and tea was in sight when Critchley's concentration wavered as Patel lured him down the pitch and raced away in celebration when Tom Moores whipped off the bails.
Notts took the new ball as soon as it became available but the breakthrough did not come with Hudson-Prentice and McKiernan playing calmly as the overs ticked away.
Ball came back at the Radcliffe Road End and had Hudson-Prentice dropped on 61 by Mullaney, diving across from second slip but in the same over, he squeezed one through McKiernan's defence to break a stand that added 65 in 23 overs.
But Derbyshire continued to fight with Cohen twice driving Ball to the cover boundary as the target came down to 27 from five overs.
Hudson-Prentice pulled the first ball of the next over from Ball for four and then lifted Patel over mid-on to leave Derbyshire needing 13 from three.
That came down to five from the final over and Cohen completed a memorable day for him and Derbyshire when he swung the penultimate delivery from Ball to midwicket for the winning runs.