Somerset 146 (Morkel 3-19, McKerr 3-20) and 168 for 3 (Azhar Ali 61*, Hildreth 60) trail Surrey 485 (Elgar 110, Stoneman 85, Burns 78, Roy 63) by 171 runs
Surrey were frustrated by the weather and some stiff Somerset resistance on the third day of the Specsavers County Championship match at Taunton.
By the close of a day limited to 49.3 overs by rain and bad light, the hosts had reached 168 for three in their second innings and required a further 171 to avoid an innings defeat.
The match looked set to end inside three days when Somerset crashed to four for two, following on, Marcus Trescothick bagging a pair when dismissed by Morne Morkel for the second time in the match.
But from there the home side found a resolve that was missing from their first innings batting, James Hildreth making 60 and Azhar Ali ending the day unbeaten on 61.
Overnight rain prevented play getting underway until noon and when it did Somerset's last wicket pair of Josh Davey and Jack Leach added 24 before Davey looked to drive Morkel and was caught at point by Mark Stoneman.
Somerset were all out for 146 and were soon in trouble in their second innings as Morkel bowled Trescothick in the opening over.
Tom Banton hit a sweet on-drive for four off Tom Curran, but was bowled next ball and the hosts' brittle batting in recent games looked set to repeat itself.
Surrey could sense victory in the air as Hildreth walked out to the middle to join Azhar. Bu the third-wicket pair gradually grew in confidence and in the 13th over a blistering cover drive from Azhar off Conor McKerr saw the Somerset 50 up.
The duo continued to prosper and Hildreth went to his half-century with a single off McKerr to square cover, his runs coming off 68 balls with eight fours.
Two overs later Azhar edged McKerr to the third-man boundary to bring up 100, shortly after which the players left the field for bad light for an early tea.
When play resumed only two more balls were possible before the players went off again due to more bad light.
After an hour, play resumed with the loss of 16 further overs. Tom Curran switched to the Somerset Pavilion End and in his second over made the vital breakthrough when he tempted Hildreth to drive at a fuller ball and edge to wicketkeeper Ben Foakes.
In his next over Curran was unlucky to have Azhar put down at second slip when he was on 30. The former Pakistan captain survived and rode his luck, taking two boundaries to deep backward square leg in the young paceman's next over.
Azhar went to his fifty with a boundary to backward square off McKerr, having faced 97 balls and hit nine fours.
Somerset had moved onto 168 for three off 42.2 overs, when bad light stopped play bringing an early close to proceedings, by which time Azhar and Tom Abell (21 not out) had added 61.