The match was apparently going nowhere when Yorkshire were 226-4 with 23.3 overs left on day three.
Gary Ballance and Jack Leaning were at the crease and solidly repelling a Somerset attack on a typically flat Taunton surface.
But beneath thick cloud cover, with rain and bad light having earlier claimed 36 overs in the day, Yorkshire lost 5-11 in 30 balls to slip to 237-9. Steve Patterson and Jack Brooks improbably added an unbroken 69 for the last wicket, but a closing total of 306-9 took the remnants of a threadbare crowd by surprise.
Trailing by 256, Yorkshire are still 107 short of avoiding being asked to bat again.
Heavy rain is predicted, however, and Somerset ideally needed to make Yorkshire follow-on last evening to give themselves the best chance of victory given the conditions, both meteorological and cricketing.
The clatter of wickets yesterday came after the weather relented to allow 30 overs from 4.45.
Leaning’s dismissal triggered the collapse, the right-hander having been given a testing working over by Lewis Gregory before the same bowler drew him into an outside edge.
A hint of panic crept in when Adil Rashid was run-out following a mix-up with Ballance, who played Tim Groenewald past backward-point, from where Tom Abell retrieved and returned with Rashid three-quarters of the way towards the batsman’s end in pursuit of a third.
Perhaps unsettled by his part in it all, Ballance fell in Groenewald’s next over when he was caught behind trying to defend.
Three balls later, Andrew Hodd played back to a delivery that kept low and lost his middle stump, and Groenewald struck again in his next over when Liam Plunkett was caught behind by Ryan Davies.
There were still 18.4 overs left when the ninth wicket fell, but Patterson and Brooks frustrated Somerset as they rode their luck and played some good shots too, restoring order in unlikely style.
Brooks finished unbeaten on 34, from 51 balls with six fours, and Patterson on 32, from 69 deliveries with three fours.
Their stand is just two shy of Yorkshire’s best for the 10th-wicket against Somerset – 71 by Hubert Myers and Haworth Watson at Bath in 1909.
After two days of generally warm and sunny weather, cloud was clinging to the Quantock Hills when play began yesterday on time.
Will Rhodes was an early casualty, adding nine to his overnight six before miscuing a pull off Peter Trego to deep-ish mid-wicket, where Jamie Overton clutched the catch.
Adam Lyth, 80 overnight, uppercut Overton for six to bring his hundred into view, and he duly reached three figures from 174 balls with his 11th four when he stroked Trego to the cover rope.
Immediately, the umpires took the players off for rain and called an early lunch for 12.30, with Yorkshire 167-2 in reply to Somerset’s 562-7 declared.
When play resumed at 1.45, Lyth added five before he was third out, smartly caught at first slip by Jim Allenby as he tried to drive Gregory off the back foot through the offside.
The chance flew quickly to Allenby, who clutched it instinctively, and he then took an easier slip catch when Andrew Gale edged the left-arm spin of Jack Leach to leave Yorkshire 189-4.
At least the performance of Lyth was a positive for the visitors, the left-hander putting an emphatic end to a sequence of six successive low scores since his hundred against Hampshire in the opening Championship game of the season.
That tough run of form put paid to his hopes – temporarily at least – of returning to the Test team, and this was a timely innings as England prepare to do battle against Sri Lanka at the Headingley ground where Lyth made a hundred last summer against New Zealand in only his second Test.
If Lyth played at Taunton each week, he would undoubtedly never have lost his place, and he took his record here to 806 runs in seven Championship games at 67.16.
This was his third hundred at Taunton and an impressive one too, his runs arriving from 180 balls and containing 12 fours and three sixes.