Yorkshire 327 (Fraine 106, Clark 5-77) and 352 (Lyth 68) beat Surrey 362 (Stoneman 100) and 194 (Elgar 71) by 123 runs
With only five minutes to spare, an enthralled crowd fearing the worst, and the only sound across North Marine Road coming from a lone seagull, Yorkshire finally broke Surrey's resistance to claim victory in a Championship encounter that built gradually into one of the most rewarding matches witnessed on the ground in the modern era.
The final incursion was made by Duanne Olivier, Yorkshire's South African pace bowler, whose fullish outswinger had Gareth Batty caught by Adam Lyth at second slip. Olivier raced towards the popular banking, his index finger brandished in triumph. Some spectators were so overcome with delight that Yorkshire had ended a four-match losing run at Scarborough that they lined up alongside the pavilion to give them an impromptu guard of honour as they left the field.
The pitch was on the slow side, but it offered turn on the final day and produced a magnificent contest watched by nearly 12,000 spectators over four days of grimy cricket under largely blue skies. Scarborough's 10-year ground contract ends this year, but negotiations can be expected soon on what will probably be another five-year term after which point the framework of county cricket is not easily predicted.
Surrey took more shifting than a monster seagull being removed from a discarded pasty and chips. Jamie Smith, 18 years old, and a veteran of only four first-class matches, remained unbowed with 24 not out from 93 balls. Jordan Clark, who once hit six sixes on this ground in a 2nd XI Roses match, managed a single from 58 balls and even that - a full ball from Olivier which he inadvertently deflected to deep square leg - might have brought a full apology.
But shifted they were after beginning the final hour at 175 for 7. Yorkshire's captain, Steve Patterson, juggled his bowlers repeatedly. The occasional offspin of Jack Leaning looked as potent as anything. But it was Olivier who struck five overs in when he bowled Clark with a full-length ball from around the wicket. In the next over, Morne Morkel followed in ridiculous fashion, creeping down the pitch from the non-striker's end in search of a single to point and finishing flat on his back with legs outstretched as Tom Kohler-Cadmore ran from second slip to run him out.
For Yorkshire, there remains an outside chance of a Championship challenge. They are now third, 36 points behind the leaders Somerset and the top two, Essex and Somerset, are up next. Surrey, the defending champions, in all likelihood face a season of mid-table obscurity.
A successful Surrey pursuit of 318 in 83 would have represented the third highest Championship run chase at Scarborough. They were well placed at 136 for 1, requiring another 182 at four an over, with Yorkshire's control largely reliant upon the South African left-arm spinner, Keshav Maharaj, whose 3 for 69 in 33 overs - despite five Surrey left-handers in the top six - underlined the shrewdness of the decision to call him in on a month's loan.
Last September, Maharaj had been involved in the first tie in the Championship for 15 years when he took 7 for 37 as Lancashire bowled out Somerset for 77, and he might have wondered if he would figure in another one.
Maharaj was into his 11th over before he struck for the first time. Surrey had scooted ahead against the new ball, but at 79 for 0 a breakthrough was overdue. It came via the first of two excellent catches at short leg by Will Fraine, Mark Stoneman caught low down off the meat of the bat.
Yorkshire were again in urgent need of a wicket when Scott Borthwick drove at an inviting wide delivery from David Willey with just a hint of outswing and lost his middle stump via an inside edge.
Wickets had fallen in clusters against the old ball throughout the match and it happened again as Surrey then lost five wickets for ten runs in six overs. Three came in five balls just before tea, the first of them Dean Elgar, vitally run out for 71, betrayed by his partner, Ryan Patel, who changed his mind on a non-existent single to mid-on whereupon David Willey dived to throw down the stumps at the non-striker's end. The way Maharaj and Patterson had bowled dry deserved some credit for that.
Ben Coad then removed Ben Foakes and Sam Curran for ducks in the next over - the last of the session. The delivery that bowled Foakes was classic Coad, nothing showy but doing just enough to beat the outside edge and hit his off stump. "A mad ten minutes which took the wind out of our sails," said Surrey's coach Michael di Venuto.
Wickets continued to fall after tea with Maharaj now to the fore. He had Patel caught at short-leg by Fraine and Rikki Clarke caught behind for a duck, but his turn and bounce was limited enough for Patterson to increasingly look elsewhere as the clock ticked down.
The first 12 overs of the final day should not pass unnoticed. Yorkshire began with a lead of 268 and their last pair at the wicket. Thirty-eight minutes later, they had extended that lead by another 49. Coad returned a career best 48 off 42 balls, including seven fours and a six over long-on against Batty. Batty turned one to have him caught at the wicket, but the damage had been done.

David Hopps writes on county cricket for ESPNcricinfo @davidkhopps