A magnificent seven-wicket haul from Theo Smith was not enough to help Scarborough to a winning finish to the YPL North season at home to relegated Castleford.
Smith took 7-47 but was unable to prevent Castleford signing off with victory in the day's closest finish as the visitors salvaged some pride from a difficult season.
Liam Hyde (45) and Mohammad Waqas (34) put on 63 for the second wicket but when the last six wickets added only 21 runs their side were all out for 149.
Smith then made 33 before the visotors fought back reducing the hosts to 89-8 with two wickets each for Connor Hyde (2-38), Daniel Robson (2-21) and David Wainwright (2-29).
A partnership of 43 between Kristian Wilkinson (24no) and Jack Holt (18) got their side in sight of victory but Eddie Morrison (4-28) held his nerve in the closing overs to bowl out the home side 10 runs short of their target.
York openers Duncan Snell (92) and Yorkshire star Jack Leaning (89) produced the league's first double century stand, the pair's 205 proving the perfect springboard for a total of 324-4 despite rain reducing the match at Driffield Town to 45 overs a side.
The total also included 58 from Liam McKendry while Jamie Hopper finished with figures of 3-70.
Sam Drury (65) took the game to the visitors but lacked support as Dan Woods (6-59) and Tom Pringle (3-24) spun York to victory by 182 runs securing them runners-up spot.