Durham 401 (Jennings 201*, Footitt 5-90) and 246 (Stoneman 92, Clark 54, S Curran 7-58) beat Surrey 367 (Roy 120, Onions 5-90) and 259 (Roy 96, Ansari 51, S Curran 50*) by 22 runs
Ben Stokes finally came to the party for Durham, ending their relegation worries by taking four Surrey wickets in a gripping finish at Chester-le-Street.
After scoring 24 and nought, and remaining wicketless until the final session, Stokes took 4 for 54 as Surrey were dismissed for 259 to lose by 21 runs.
Jason Roy fell four short of his second century of the match, but Surrey were kept in the hunt by a fearless unbeaten 50 from 18-year-old Sam Curran to go with his 7 for 58 in Durham's second innings.
Surrey could have slight concerns over Roy and Zafar Ansari ahead of Saturday's Royal London Cup final after both needed treatment for hand injuries.
Following their first innings stand of 164 the pair put on 143 after coming together at 11 for three in pursuit of 281. After the persistent murk of the previous day, play again began with the floodlights on, but the sun was starting to emerge as Roy went to the crease and batting became more comfortable after lunch.
On nine Durham were convinced Roy had edged Brydon Carse's first ball to wicketkeeper Stuart Poynter, then he edged the next ball where third slip had been prior to becoming a second gully.
He played with calm authority afterwards, but was struck on the hand by Carse on 44. After a lengthy delay he hooked the paceman to fine leg for one of the nine fours in his 79-ball half-century.
Ansari was on 32 when he needed treatment following a ball from Mark Wood. Two on-driven fours off Graham Onions provided the highlight as he progressed to 51.
Durham had to turn to Scott Borthwick and in his second over he turned one sharply into the left-hander to have him lbw on the back foot.
Roy's 132-ball innings was ended by the first ball after tea when he gloved an attempted pull off Stokes to the wicketkeeper.
Sam Curran cracked Stokes to the cover boundary three times off the back foot before the England all-rounder tightened up with three successive maidens, the last of which included two wickets.
A stand of 54 ended when Ben Foakes pushed firmly and edged to Borthwick at second slip.
Two balls later Tom Curran edged to Poynter, bringing in Gareth Batty with 59 needed. He helped to add 30 before falling to a stunning catch by Keaton Jennings, diving to his left at third slip.
Onions took the last two, Stuart Meaker edging a drive to first slip before Mark Footitt had his stumps splattered.
In the morning murk Durham's two remaining wickets added 33. Curran took his seventh when Onions drove a full toss to mid-off and Durham were all out for 246.
Wood quickly took two wickets when Surrey batted, producing a snorter to have Kumar Sangakkara well caught by Poynter second ball.
It didn't look good for Surrey, but Roy, Ansari and the younger Curran ensured a thrilling climax.