De Bruyn and Kieswetter then revived the innings with a partnership of 108 in 28 overs.
Somerset's chance had gone and De Bruyn's brave innings ended with a perfectly pitched leg-break from Rashid.
But Zander de Bruyn was 36 not out when shadows across the pitch ended play five overs early.
Justin Langer (79), Craig Kieswetter (67), Zander de Bruyn (62no) and Arul Suppiah (51) saw Somerset to 316-5.
Zander de Bruyn gave them hope with his first Somerset century and Ian Blackwell contributed a defiant 64.
But, after De Bruyn's dropped catch, Yardy played a key role, helping Hamilton-Brown finish the game with a flourish.
Hampshire's relief did not last for long as De Bruyn, despite a slow start, piled on more runs with an 89-ball half-century.
From 142-5, De Bruyn and Craig Kieswetter combined for a century partnership in 32 overs, the second fifty coming from 12 overs.
Earlier, South African duo Craig Kieswetter (106) and Zander de Bruyn had laid the foundations for Somerset's 285-8 in a 167-run fourth-wicket stand.
An unbeaten 75 by Zander de Bruyn further compounded Hampshire's woes as the hosts ended day three 326 runs ahead with five wickets remaining.
Thomas had Samit Patel lbw with a delivery that may have been sliding down the leg-side and Zander de Bruyn removed Ali Brown soon after.
De Bruyn went on to his first century for Somerset, off 214 balls, and a draw looked the favourite when Alfonso Thomas shut up shop.
And then, at the death, de Bruyn dropped Rory Hamilton-Brown at deep cover off the first ball of the 48th over with 27 runs still needed.
From then on it was all about Kieswetter and De Bruyn, who put together a sensible and at times exhilarating partnership of 167 in 30 overs.
As ever, former Surrey man Brown was keen to get on with things, showing his intent by twice lifting Zander de Bruyn straight back down the ground.
Tim Bresnan accounted for Arul Suppiah (19) but Hildreth, who hit nine fours, and Zander de Bruyn calmed any Somerset nerves with a fourth-wicket stand of exactly 100.
De Bruyn became the fourth Somerset player to reach fifty in the innings when he hit Sidebottom to the extra cover boundary from the 110th ball he had faced.
Yorkshire had to wait until after lunch for their next success when de Bruyn, on 45, was taken by Adam Lyth at short leg to become leg-spinner Adil Rashid's first victim.
The scoreboard read 54-4 but Blackwell survived a sharp chance to Rudolph at slip on eight and by lunch he and De Bruyn had taken the score to 115 without further loss.
De Bruyn was reprieved on eight when Pattinson spilled a low caught and bowled chance, and the seamer suffered more disappointment when De Bruyn and Kieswetter took 26 off two of his overs.
Left-arm seamer James Tomlinson, who was awarded his county cap at the start of this match, picked up Arul Suppiah and then Zander De Bruyn for a fifth ball duck when the score was 55.
Zander de Bruyn hit a six and a four off one over from spinner Sherwin Ganga in an enterprising knock of 43 not out, but Bravo collected two wickets in the final over to finish with 4-23, and Somerset's fate is now out of their hands.
应用推荐