Glamorgan 188 for 4 (Balbirnie 99*) beat Gloucestershire 171 for 6 (Dent 55, Wagg 3-34) by 17 runs
Ireland captain Andy Balbirnie fell agonisingly short of becoming Glamorgan's sixth centurion in T20 cricket as he led his side to a well-earned victory over Central Group leaders Gloucestershire by 17 runs in the Vitality Blast in Cardiff.
Balbirnie struck an explosive unbeaten 99, the highest individual T20 score by a Glamorgan batsman at Cardiff, to lay the foundations of a competitive 188 for 4, adding 61 for the second wicket with David Lloyd and 79 for the fourth with Chris Cooke.
Defeat for the visitors means that they must now wait until their final match against Somerset on Sunday to discover whether they will have a home tie in the quarter-finals.
Glamorgan made three changes to the side that lost heavily to Somerset at Cardiff two nights ago - top-scorer Owen Morgan, Callum Taylor and Marchant de Lange replaced by Kiran Carlson, Dan Douthwaite and Graham Wagg.
Openers Lloyd and Nick Selman lofted the ball for a boundary apiece before the latter holed out to deep midwicket. However, Balbirnie continued the onslaught as Glamorgan reached 51 for 1 at the end of the Powerplay.
Gloucestershire turned to the medium-pace of Benny Howell and Ryan Higgins, and then to the left-arm spin of Tom Smith - and it yielded success when Lloyd was bowled by Howell as he stepped away to the leg side, before Carlson drove Smith to Howell at cover.
Balbirnie swept Taylor to the fine-leg boundary for his second six, bringing up his half-century, and continued to blast the Gloucestershire attack with Higgins conceding 17 in his second over. Balbirnie waited nervously for his century, as Cooke was run out attempting a quick single, before Douthwaite despatched consecutive boundaries, but the Irishman ultimately fell one run short.
Chasing 189 to win, Gloucestershire made a slow start to their Powerplay, despite two fours and a six by Chris Dent in the fourth over, before Mile Hammond was caught at short third man in the fifth as the visitors reached 49 for 1.
By the halfway stage, Dent, who was dropped by Salter before reaching his half-century from 32 deliveries, and Ian Cockbain, also dropped by Timm van der Gugten in the deep, had guided Gloucestershire to 86 for 1, still requiring 103 runs to win.
Graham Wagg gave Glamorgan important breakthroughs in successive overs, when he struck the top of Cockbain's leg stump before catching Dent at long-off off Prem Sisodiya. He struck again when the equation was 65 from the final five overs as John Bracey, dropped at long-on on 29, skied to point from a leading edge on 37 in the 18th over.
Van der Gugten yorked Higgins from the final delivery of the penultimate over, and Wagg claimed a third wicket in the final over when Jack Taylor was caught at long-off as Balbirnie rounded off a memorable evening for the Dubliner.