The 35-year-old left-arm seamer began by contributing a valuable 36 to help his side extend their first innings total from an overnight 144-5 to 280 all out, Aneurin Donald making 57 and James Fuller a rapid 38.
That gave Hampshire a lead of 69. Barker then got to work with the ball, combining extravagant swing with nagging accuracy to claim 6-27 from an unbroken 13-over opening spell as Somerset crashed to 25-6 before being bowled out with the scores level.
The hosts’ 69 was the lowest team total recorded in the Championship this year.
'Is proving one hell of a signing.... A real livewire' - Portsmouth match ratings from 2-0 win at Cheltenham
Portsmouth boss provides latest transfer development on former Millwall, Luton and Wigan midfielder as Fratton Park exit looms
Portsmouth boss Danny Cowley hails squad depth as tactical masterclass at Cheltenham pays off
RECAP as Colby Bishop steal show as Portsmouth edge Cheltenham at sun-soaked Whaddon Road
Cheltenham 0-2 Portsmouth: Colby Bishop steals show as Blues prove too hot to handle in impressive display at sun-soaked Whaddon Road
Opener Felix Organ hit the required single for victory off the fourth ball of Hampshire’s second innings and his team took 21 points to Somerset’s four to enhance an impressive start to the Championship campaign.
Hampshire are now just two points adrift of top flight leaders Surrey after winning four of their opening six games.
And Barker, with 27 victims at 16.74, is the joint second highest wicket-taker in the Championship. Only Durham’s Matt Potts - called up by England last week - has taken more (35 Division 2 wickets).
It was also Barker’s second best first class figures, beating the 6-40 he took against Somerset at Taunton while playing for Warwickshire a decade ago.
‘At the start today nobody expected what has happened,’ said Barker,
“We were just trying to get ahead with the bat. We knew that if we could get a lead of 50 or 100 it would be very difficult for them, but we were never expecting ten wickets in a session.
‘The pitch offered a lot throughout the whole game. I just kept on plugging away and it was my turn to take wickets this innings.
‘Other lads took them in the first innings, so it has been a good all-round team performance.
‘We changed our lines a little bit today and it seemed to work for us. Even so, it was a surprise for the game to finish on day three, especially with yesterday when it rained for quite a long time.’
The day began with the visitors trailing on first innings by 67. Ben Brown failed to add to his overnight score of 19 before being pinned lbw by Peter Siddle with the total on 152.
At 154-6 in the 59th over the ball had to be changed for the second time in the innings. By then Donald was showing a desire to get on the front foot, profiting from some sweetly timed drives as he and Barker ate into Somerset’s lead.
A key moment came on 195-6 when Donald, on 29, was dropped by Craig Overton at gully off Josh Davey.
It was an error the home side could ill afford. Barker had moved confidently to 26 when greeting the introduction of England spinner Jack Leach with a six and a four off his first two balls.
The first of those shots put Hampshire in front. The next delivery saw Barker caught at mid-wicket, but Donald went to a 74-ball half-century before falling to the second new ball, bowled by Siddle.
Kyle Abbott fell cheaply to Overton, but Fuller ensured Hampshire of a meaningful advantage, striking four fours and two sixes as Somerset bowled poorly during a last wicket stand of 24 with Mohammad Abbas.
Overton and Siddle ended with four wickets each. But momentum was with Hampshire and a series of wretched shots contributed to the home side’s nightmare second innings.
Tom Lammonby was caught behind for a duck off Abbas, while opening partner Matt Renshaw was trapped lbw on his crease by Barker to make it 12-2.
Tom Abell followed a leg-side delivery from Barker and glanced a catch to Ben Brown before Tom Banton top-edged an ill-judged pull off Abbas to give the wicketkeeper another victim.
James Hildreth moved to 18,000 first class runs with a single to get off the mark, but it proved his only contribution as he was bowled by a full, swinging ball from Barker.
A similar delivery saw Lewis Gregory fall leg-before and Somerset were in disarray. Overton helped Steve Davies add 32 before being bowled by another full Barker delivery for 13.
The home batting line-up lacked the technique to cope with the swinging ball. Another loose shot saw Davies, on 19, have his leg stump uprooted by Abbott.
Leach was brilliantly caught at cover by Nick Gubbins, having middled a drive off Abbot. After Davey had brought the scores level with a glanced boundary off Barker, an embarrassing Somerset batting effort ended with him being bowled next ball shouldering arms.
The T20 Blast tournament now takes centre stage for a while in the county calendar, with Hampshire returning to Championship action against Yorkshire at The Ageas Bowl on June 12.