Needing 259 to win, Somerset began day three on 39-0 and Dean Elgar and Marcus Trescothick reached 58 without loss.
But the hosts then lost three wickets for 15 runs and, despite a half-century from Elgar, the game moved Hampshire's way when his dismissal made it 118-6.
Mason Crane (5-40) and Liam Dawson (4-66) secured victory before tea.
Hampshire, who temporarily go top of Division One, have lost just one of their opening five games, including their other away win, against Yorkshire at Headingley in the opening game in April.
On a pitch that offered plenty of spin, Crane's effort proved crucial, as seven Somerset batsmen failed to reach double figures.
South African Elgar was top scorer in the match, hitting 60 in both innings, but when Crane's long hop bowled him on the second bounce, it turned the game in Hampshire's favour.
Somerset, who now travel to Lord's to face reigning champions Middlesex this Friday, trail Warwickshire by five points at the foot of the table, 15 adrift of safety.
Hampshire coach Craig White told BBC Radio Solent:
"It was a great comeback and we are obviously delighted to have won. We had a blip last week against Essex, but it was always going to be about how we responded.
"We felt that the first partnership for Somerset was key to them. If we broke that pair up, we could look at chipping away. We did exactly that and bowled really well.
"A great first session was what we needed. And I felt the bowlers showed brilliant discipline with the ball."
Somerset captain Tom Abell told BBC Radio Bristol:
"It's not good enough. It was a massively disappointing day and it has been a massively disappointing start to the season.
"What is even more disappointing is the fact that we have been in a strong position in all three of the Championship games we have lost. We have got to be more ruthless.
"The bowlers have bowled really well. It's the batsmen that are letting the side down. But it's us who have got us in to this mess. Now, it's up to us to get us out of it."
Hampshire claimed their second away win of 2017 to inflict a third loss from four Division One games this season on bottom-of-the-table Somerset.