Unbeaten tons by Justin Langer (111) and Ian Blackwell (104) helped Somerset from 73-3 to 335-4 against Surrey.
Resuming on 280-7, Surrey were all out for 326, and thanks to Blackwell and Langer, who was dropped on nought, Somerset led by nine runs at stumps.
Openers Marcus Trescothick and Neil Edwards made 67 before both were out for the addition of just five runs.
James Hildreth's duck brought Langer to the crease, and Blackwell joined him when Zander De Bruyn was out for 41.
Jonathan Batty and Saqlain Mushtaq added 37 runs to Surrey's overnight total before Saqlain was out lbw to Charl Willougby for 14.
Alfonso Thomas bowled Jade Dernbach in the next over for a duck, and four overs later Pedro Collins went the same way to the same bowler for the same score.
Trescothick and Edwards got things off to a brisk start for the visitors before Edwards' dismissal, and five runs later Trescothick followed him, caught by Mark Butcher off the bowling of Dernbach.
Hildreth was out lbw to Collins, which brought Langer to the crease, and that steadied the ship.
Butcher's failure to hold on to a slip chance proved costly as Langer went on to make his 83rd first-class century from 141 balls.
Blackwell was also dropped in the slips, on 76, and went on to reach three figures off 111 balls with eight fours and three huge sixes.