South Australia will face Victoria in the Sheffield Shield final after NSW fell narrowly short in an extraordinary finale to their match against Western Australia at the WACA.
Needing a win to hold on to second place, NSW appeared on course throughout Sunday to chase down an improbable victory target of 402.
However, the visitors lost seven wickets in the final session to suffer an agonising six-run defeat, with 10 balls remaining.
Part-timer Ashton Turner was the unlikely hero for Western Australia, taking 6-111, with the offspinner having taken only five wickets in 17 previous first-class matches.
Quick Single: Redbacks claim Shield final berth
Wicketkeeper Peter Nevill seemed to be the hero for the Blues after watching the NSW tail fall apart around him.
When No.11 Harry Conway came to the wicket the Blues needed 24 off 5.3 overs, and with Nevill protecting his colleague from much of the bowling, that target became 17 off four, 12 off three overs, and then seven off the final two overs.
However, the former Test 'keeper was caught reverse sweeping off the bowling of Turner for 63.
NSW began the final session at 3-256 and required a reachable 147 runs off 37 overs.
The Blues advanced to 3-292 before Kurtis Patterson was bowled by Turner for 39.
When big-hitting Blues skipper Moises Henriques went soon after caught at deep mid-off from the bowling of Turner for a run-a-ball 66, the momentum began to swing back towards the hosts.
Western Australia's Shield final hopes had evaporated before they took the field on the final day as South Australia moved into second thanks to their win over Tasmania in Hobart.
The home side, however, were intent on sending retiring skipper Adam Voges out on a high.
A 161-run partnership for the second wicket between NSW opener Daniel Hughes (110) and the in-form Ed Cowan (80) seemed to be a strong enough platform for the Blues to achieve the unlikely win.
The final will be played over five days from March 26 in Alice Springs.