Glamorgan 161 and 237 for 8 (Wagg 64*, Cooke 53, Panesar 5-90) need a further 111 runs to beat Essex 286 and 222 (Ten Doeschate 63*, Smith 58)
Monty Panesar completed a match haul of 10 wickets to help Essex to the brink of victory going into the final day of their against Glamorgan at Swansea.
Panesar followed up 5 for 50 in the first innings with 5 for 90 in the second. But, despite claiming an extra half-hour on the third evening, Essex failed to take the final two wickets with Glamorgan finishing the third day 237 for 8 after they had been set 348 to win.
Essex, who were down two bowlers - Graham Napier and Ryan ten Doeschate with calf and shoulder injuries respectively - were frustrated by an impressive 64 not out from Graham Wagg, who ensured the match went into a fourth day.
The visitors began the day on 131 for 5 and were bowled out for 222. Greg Smith, who had been dropped first ball on Saturday evening, went to his second half-century of the season from 88 balls with eight fours and one six. Ten Doeschate struck Dean Cosker for two consecutive sixes over long-on and then pulled him for another six over midwicket to bring up the 100 partnership and his own half-century from 99 balls.
After a productive hour for the visitors, Glamorgan grabbed the breakthrough when Smith edged behind attempting to cut a wide one from Jim Allenby. It left Essex 195 for 6, leading by 320.
Napier, batting with a runner, only lasted 10 balls, playing on to James Harris. The next wicket occurred in bizarre circumstances when Sajid Mahmood was run out coming back for a second after colliding mid-pitch with ten Doeschate.
As well as Mahmood being dismissed, ten Doeschate also retired hurt after facing one more ball, but returned to the middle after Panesar drove a return catch to Harris. And a return catch ended the innings when Allenby took a sharp one-handed effort to remove Matthew Salisbury.
Glamorgan were left 20 minutes to survive before lunch but Panesar, who opened the bowling, broke through Jacques Rudolph's defences as the home side limped to the interval at 13 for 1.
After lunch Will Bragg became Panesar's third victim, sweeping to midwicket before Glamorgan steadied things and from 24 for 2 as Murray Goodwin and Chris Cooke put on 87.
Glamorgan had reached 111 for 2 when Panesar trapped Goodwin lbw on the back foot and on the stroke of tea Nick Browne's leg-spin nearly accounted for Cooke, who edged past first slip to bring up his 50 from 92 balls with nine fours.
Only six balls after tea, Panesar bagged his fourth wicket when he had Cooke caught at slip by Jessie Ryder. The hosts then slipped to 144 for six when Allenby glanced Tom Westley straight to the substitute fieldsman Tim Phillips at leg slip and Panesar completed 10 wickets in the game when he trapped Mark Wallace leg before.
Glamorgan's innings went from bad to worse as Andrew Salter was dismissed second ball by Westley, caught at leg slip by Phillips attempting to sweep. There was some resistance shown from Wagg and Harris, who put on 76 in an hour. But, 15 minutes before the scheduled close, Harris went lbw to Greg Smith. Wagg went on to complete his fifty from 74 balls, though, and Essex could not snare the final two wickets despite claiming the extra half-hour.