Jos Buttler's intelligent innings of 68 not out guided Somerset into the Yorkshire Bank 40 semi-finals with a 12-run victory over arch-rivals Gloucestershire Gladiators at a packed County Ground, Bristol.
Buttler reined himself back on a two-paced pitch as wickets fell around him before the visitors, who lost the toss, posted 259 for nine.
Marcus Trescothick contributed 50 and Craig Kieswetter 42, but the highlight of the innings was a hat-trick from left-arm spinner Tom Smith, who returned 3-46.
Gloucestershire replied with 246 for seven, having been given a good start by Michael Klinger and Hamish Marshall.
Alex Gidman, Chris Dent and Ian Cockbain made a fight of it, but Alfonso Thomas used his experience to frustrate the hosts with 3-41.
It was a sad end for Gloucestershire to a day that had seen the opening of their plush new Bristol Pavilion, but results elsewhere meant that even a victory would not have put them in the semi-finals. Somerset ended as Group C winners with a superior run-rate to Glamorgan's.
Trescothick and Kieswetter gave Somerset a great start to their innings with a century stand inside 13 overs.
The ball after reaching his half-century, off 45 deliveries, with seven fours and a six, Trescothick was deceived by Craig Miles and drove a simple catch to cover.
Nick Compton fell first ball, guiding a Miles full-toss to Ian Cockbain at backward point, and it was 126 for three when Kieswetter, who had struck two big sixes, nicked a catch behind as he looked to pull a short delivery from David Payne.
James Hildreth and Buttler were content to largely milk singles in a stand of 71 off 12.2 overs, which looked to have put Somerset in a strong position again.
But Smith had other ideas, sending back Craig Meschede, caught behind, and Lewis Gregory, who drove a catch to cover, with the fifth and sixth balls of the 30th over before completing his hat-trick by bowling Piyush Chawla with the first delivery of the 32nd.
Buttler was left in a difficult position, as his team lost wickets in a cluster for the second time, and left it until the last over to produce his trademark scoop shot off James Fuller to achieve his first six. He hit only four fours in facing 71 balls.
Gloucestershire looked well in it as Klinger and Marshall put on 63 in less than 10 overs before the latter drove a catch to long-off to give Somerset's recent overseas signing Chawla his first wicket for the county.
A key moment came when Chawla claimed a tumbling catch at short fine-leg off Steve Kirby to dismiss Klinger, who clearly felt the ball had bounced. After the umpires had consulted he was sent on his way and it was 92 for two.
From then on the home side were always struggling to keep up with a run-rate that grew steadily from 6.5 an over to reach 10 by the last five overs.
The canny Thomas used a succession of slow bouncers to good effect and, as Somerset's batsmen had found, it was not a pitch conducive to hitting a lot of boundaries.