Yorkshire 188 for 8 (Shafique 64, Revis 52, van Beek 3-35) beat Leicestershire 185 (Rehan 43, Cox 43, Sutherland 3-20, Milnes 3-37) by two wickets
Yorkshire ensured they would at least not finish bottom of the North Group table as they ended a disappointing season with a two-wicket away victory over Leicestershire Foxes in the Vitality Blast after a dramatic finish at the Uptonsteel County Ground.
Needing 13 off the last over, they looked to have missed out when a brilliant piece of combination fielding saw Jordan Thompson out with three balls left and 11 still needed, only for Matt Milnes to hit Josh Hull for back-to-back sixes off the last two deliveries to clinch the points.
Leicestershire, who began the night still with an outside chance of qualifying for the quarter-finals, contingent first on them winning, posted 185 but after Ben Cox (43 from 27 balls) and Rehan Ahmed (43 from 29) provided the platform for a 200-plus total they lost their last six wickets for 24 and were bowled out in 18.5 overs.
Although Milnes was the star at the death, Pakistan international Abdullah Shafique (64 off 38 balls) and Matthew Revis (52 off 32) had made it possible with a county record fifth-wicket stand of 122 as Yorkshire recovered from 23 for four.
Milnes had earlier taken 3 for 37 with his seamers, with Will Sutherland (3 for 20) also impressive with the ball. Logan Van Beek took 3 for 35 and Ian Holland 2 for 19 for Leicestershire.
Defeats in three of their previous four matches had left Leicestershire needing to win their final match and hope results elsewhere went in their favour if they were to finish in the top four. But victories for Bears and Durham both recorded victories to make this result academic.
Leicestershire started well after Yorkshire had opted to bowl first, although 62 on the board in the powerplay cost them three wickets, Sol Budinger, Rishi Patel and Shan Masood out after making starts, two of the wickets to Dan Moriarty's left-arm spin.
Rehan and Cox added 81 in 46 balls to give the Foxes a platform for a big score, Rehan hammering Moriarty and then Jordan Thompson over the long-on boundary before skewing to deep cover, Louis Kimber maintaining the momentum by going 4-6-4-6 against Jafer Chohan's wrist spin.
But after Cox was leg before to Sutherland at 161 for five in the 16th, the innings rather fell apart, Milnes taking three wickets in an over to dismiss Logan Van Beek, Ian Holland and Tom Scriven. Kimber (27 off 12) miscued Thompson, leaving the departing Yorkshire all-rounder on 99 Blast wickets for the county.
Sutherland picked up his third, bowling Josh Hull, and though 185 looked a competitive score, having failed to use seven of the 120 balls, the Foxes had clearly left runs on the field.
Those runs were effectively clawed back as a near-exemplary powerplay with the ball from the Foxes left Yorkshire reeling at 23 for 4, despite James Wharton lifting Hull over the legside boundary in the second over.
Holland and Van Beek took two wickets each, Will Luxton and Harry Duke hitting straight to fielders in the circle, Wharton and Dawid Malan finding men in the deep, Rehan taking three of the catches.
Yet Shafique and Revis piled on the runs through the middle phase of their innings to get Yorkshire back in the game, Shafique hitting four sixes and Revis three.
The partnership looked to be over when Shafique was caught behind square off Van Beek, but the ball had deflected off his helmet. In the event, Rehan bowled him with the first ball of the next over.
Revis completed his half-century with his third six but fell in the next over, somehow skewing a ball from Hull to short fine-leg, leaving 35 needed from 17 balls. Thompson and Sutherland cleared the ropes in an expensive 19th over for the Foxes as Van Beek conceded 17, including two wides.
Nonetheless, it looked like the home side had enough until Milnes proved them wrong by hammering Hull over wide midwicket for one six, before an audacious scoop for six more off the last ball sealed the result.