Dawid Malan fell a run short of a century in reply but with a nerveless unbeaten 39 from 38 balls by Neil Dexter got the hosts home under the lights at HQ.
They were made to sweat, however, after Hildreth took 26 from the final over, bowled by James Harris, to reach 102 not out and set a defendable score of 247 for seven.
Middlesex looked to be cruising at 159 for one in the 24th over, after Malan had figured in stands of 71 and 88 with Paul Stirling and Joe Denly respectively, but a cool captain's innings by Dexter was then required after the loss of four wickets for 26 runs in eight overs.
Victory eventually arrived with five balls to spare as Dexter, Gareth Berg and Ollie Rayner, who ended a good match for him by pulling the winning boundary, dealt impressively with the pressure of having to score 55 from the last eight overs.
Stirling had fallen for 27 when he speared his 24th ball straight to mid-off, but Denly included a six over long-on against Arul Suppiah in his 31 before he went for a rash big hit against Max Waller's leg-spin and skied a catch to wicketkeeper Alex Barrow.
Suddenly panic set in and Middlesex also lost Chris Rogers for one, superbly caught low down by Marcus Trescothick diving to his right at first slip off Jamie Overton. The 19-year-old paceman then trapped Adam Rossington leg before for six with a stunning yorker.
hen Malan drove wildly at Craig Meschede's medium pace, and Barrow flung himself to his left to cling on to the edge, Somerset were right back in the game at 185 for five in the 31st over.
Dexter, however, added 44 in combative fashion with Berg, until the latter skied a leading edge to long off to depart for 17, and Rayner also played well to finish on 12 not out. The win puts Middlesex into third place in Group C.
Hildreth had earlier completed his hundred in spectacular style, hitting Harris for three successive sixes and two fours in the 40th over of the Somerset innings to boost the total.