Hampshire 141 for 9 (Wallawawita 3-19) beat Middlesex 121 (Simpson 48, Afridi 6-19) by 20 runs
Shaheen Shah Afridi took four wickets in four balls as his six-wicket haul made sure Hampshire ended their horror Vitality Blast campaign with victory over Middlesex.
The Pakistan fast bowler demolished John Simpson, Steven Finn, Thilan Walallawita and Tim Murtagh's stumps in consecutive deliveries to blow away the visitors.
Having returned a disappointing 1 for 191 across his first six outings, Afridi celebrated an incredible 6 for 19 - Hampshire best ever T20 bowling figures, and the county's second format hat-trick in their history. He became only the seventh player to take four wickets in four balls in a T20.
It meant Hampshire ended a six-game losing spell to win by 22 runs, although couldn't prevent them from finishing bottom of the group stage for the first time since 2007.
Hampshire needed quick wickets in their defence of 141 for 9, and Felix Organ continued the trend of spin it to win it as he opened the bowling with his offbreaks and had 20-year-old Jack Davies lbw.
Organ had Joe Cracknell caught at point by Joe Weatherley in his second over - the 21-year-old bowling three overs in the Powerplay and returning 2-13.
Afridi claimed his maiden Ageas Bowl wicket for the county when he yorked Stevie Eskinazi, who ended the group stage as the tournament's second-leading scorer with 413 runs.
Ryan Stevenson bowled Nathan Sowter with a slower ball before Mason Crane continued the spin domination when Tom Alsop stumped Martin Andersson.
Simpson threatened a comeback for the visitors as the run-rate climbed, he added 25 with Luke Hollman before Afridi turned the latter's off stump into a javelin.
Wicketkeeper Simpson helped take 17 off Stevenson in the 16th over, thanks to two huge sixes, as Middlesex required 37 from the last four overs.
But left-armer Afridi, who flies home tomorrow, took four wickets in four balls to provide an explosive end to a below-par season.
It was the second hat-trick taken by Hampshire this year, after James Fuller had taken a treble against Surrey in the Bob Willis Trophy.
Having chosen to bat, Hampshire ground through their innings, as partnerships struggled to flourish against an impressive spin performance on a slow pitch.
Middlesex's spin triplets of Walallawita, Hollman and Nathan Sowter took 8 for 74 in their 12 combined overs to restrict Hampshire.
James Vince chopped veteran Tim Murtagh onto his own off stump, before Alsop and Sam Northeast laid a solid foundation with a 32-run stand.
But that was as good as the batting got for the hosts as Walallawita, Sowter and Hollman constricted them. Alsop was bowled while attempting a slog-sweep off legspinner Hollman and top-scorer Northeast nicked Walallawita behind to Simpson.
Joe Weatherley split the leg side boundary riders with a perfect sweep, before he was plumb lbw when he switched into a reverse.
From 55 for 1 after eight overs, Hampshire found their recognised batsmen all dismissed by the end of the 17th over on 114 for 7.
The spinners forced the batters to play to the long square boundaries as an impatient Fuller and Organ holed out to long-on, while Ian Holland - following a six down the ground - was leg-before attempting a huge slog sweep.
The latter two scalps fell to Walallawita on his T20 debut, having impressed with his left-arm spin during the Bob Willis Trophy earlier this summer.
Stevenson found a hat-trick of boundaries off Tom Helm but leggie Sowter returned to bowl him and Chris Wood - as Hampshire bobbed to 141 for 9 in their 20 overs.