Somerset, already with a home tie in the last eight, made just 250-9 despite an opening stand of 108 between Mahela Jayawardene (55) and Jim Allenby (69).
But Hampshire lost regular wickets in the chase as they were all out for 245.
With Middlesex or Surrey set to pick up points in their match at Lord's and Kent beating Sussex, Hampshire can now only finish fifth at best.
Meanwhile, Somerset only lost one match in eight in the group stages and face Worcestershire at Taunton in the quarter-finals.
The visitors looked set for a much bigger total with Sri Lanka great Jayawardene and skipper Allenby setting a fine platform.
But once all-rounder Allenby was removed by teenage paceman Brad Wheal to leave Somerset 149-2, the rest of the innings stuttered.
Hampshire looked well placed at 184-5 after half-centuries from opener Jimmy Adams (50) and Will Smith (59), but the dismissal of Smith with 67 needed off 49 balls left the lower order with too much to do.
Gareth Andrew and Wheal hit a couple of lusty blows each to take the game to the final over, but with six needed off the final delivery Wheal could only slap the ball back into the hands of Tim Groenewald.
Hampshire went out of the One-Day Cup after a five-run defeat by South Group leaders Somerset at the Ageas Bowl.