|LV= County Championship Division Two, Swalec Stadium (day three)|
|Glamorgan 314 & 270: Wallace 79, Wagg 43, Malik 3-39|
|Essex 221 & 51-2|
|Essex need a further 313 to win|
|Glamorgan 6 pts, Essex 4 pts|
Eighteen wickets fell on the third day between Glamorgan and Essex, as Graham Wagg starred with bat and ball.
Ryan ten Doeschate (49) was caught behind off Craig Meschede in the sixth over of the day before Wagg (5-54) mopped up the tail, as Essex went from 183-4 to 221 all out, trailing by 93.
A 98-run sixth-wicket stand between keeper Mark Wallace (79) and Wagg (43) helped Glamorgan to 270 all out.
Set 364 to win, Essex lost two early wickets to close on 51-2.
|Essex set record run chase|
|If Essex score the 364 required for victory it will be their highest successful fourth-innings run-chase since they made 381-7 to beat Gloucestershire at Gloucester in June 2002.|
Following ten Doeschate's dismissal, Wagg claimed four of the final five Essex wickets as they lost their last six wickets for just 38 runs.
The left-arm seamer had Callum Taylor (26) caught at mid-on before Graham Napier edged behind for nought in the same over.
He then bowled Kishen Velani and Jamie Porter in a spell that saw him take four for seven in just 15 balls.
Porter and Adeel Malik both took three wickets each as the hosts raced to 270 in just 55.5 overs to build a sizeable lead, led by Wallace's second half-century of the season.
But Wagg struck in his fourth over of Essex's second innings as he trapped Nick Browne (13) lbw and Andrew Slater had Jaik Mickleburgh stumped as he bowled four consecutive maidens, to leave the away side 313 runs shy of their target.
Glamorgan wicketkeeper Mark Wallace told BBC Radio Wales Sport:
"It's nicely set up, we bowled well and could have had four wickets down overnight with a bit of luck.
"Hopefully we'll get some early wickets and get our first Championship win of the season. The pitch is up and down, it can get quite flat and there are also periods when there's a little bit in it.
"It was a good day for the spectators, the game went to and fro but thankfully we managed to get ourselves on the front foot, get the upper hand for a bit with the bat and to have them chasing over 350 is a great position on any last-day pitch."