Benny Howell produced an outstanding spell to see Gloucestershire defend 171 to beat Middlesex by 10 runs in the Vitality Blast at Cheltenham College.
Howell's 3 for 23 from his four overs helped deliver a victory to revive Gloucestershire's chances of qualifying from the South Group. Their sixth win of the group stage lifted them - perhaps only briefly - to second in the table.
Having lost the toss, Gloucestershire were well held for most of their innings but a late burst from Ryan Higgins, who hit 43 from 25 balls on his return from paternity leave, helped add 52 from the final four overs as the home side posted 171 for 8.
Middlesex were fairly well placed at 83 for 3 after 11 overs but fell away badly and Max Holden's unbeaten 50 in 34 balls came too late.
Mujeeb Ur Rahman had set the tone for a fine bowling performance from the away side as he bowled Miles Hammond with the fourth ball of the match and then had Howell taken at short third man in his second over. Mujeeb's four overs conceded only 23 runs.
Glenn Phillips cut Blake Cullen behind to leave Gloucestershire 26 for 3 after four overs, but James Bracey broke the shackles with a slog-sweep over deep midwicket as overs eight and nine collectively went for 33 but any momentum was ended as Bracey holed out to deep midwicket for 33 from 22 balls.
The home side needed a spark and Higgins, returning after the birth of his son on Monday, played a most necessary late hand. He swung Cullen into the pavilion and pulled Finn over midwicket.
"Ian and James played really nicely," Higgins said. "They took their chances when they needed to and then batting with Graeme - we're really good mates so it's always fun. We though 160 was probably enough but in the end we were glad for the finish we got and that was probably the difference in the game."
Matt Taylor bowled his side to victory in the Championship on Thursday and he was back to make the breakthrough in the chase as Phillips pulled off a stunning flying catch at backward point to remove a disbelieving Stephen Eskinazi. Sam Robson then drove Josh Shaw to mid-off.
Howell bowled debutant Josh de Caires and then trapped Nathan Sowter lbw first ball and with 62 needed in 30 balls, the game looked over.
But Holden flicked Higgins over short third man for four and swung him over midwicket for six. He slugged another maximum wide of midwicket to leave 40 needed from 18 balls.
Cullen then swung Shaw for three consecutive boundaries to end the 19th over to leave 17 required from the final set. It was defended comfortably by Higgins.
The defeat confirms Middlesex's group-stage elimination from the Blast, though they had already needed an improbable set of results to go their way to qualify for the quarter-finals.
Nic Pothas, their assistant coach, said: "You always ask did the opposition play well or did you allow them to play well? And this year we have allowed them to play well. "There have been some clutch moments and decision-making has been found wanting. I think the disappointing thing is we are making the same mistakes over and over."