Gloucestershire 254 and 19 for 0 need a further 413 runs to beat Essex 400 and 285 for 4 (Gambhir 106, Mickleburgh 86)
Gautam Gambhir struck his first century for Essex to help his side to a position of complete dominance against Gloucestershire. The India opener hit 106 and piled on 201 runs with opening partner Jaik Mickleburgh (86) before the visitors declared on the third evening.
Gloucestershire require a further 413 on the final day after closing on 19 without loss when bad light set in, with much resting on captain Michael Klinger and Chris Dent.
An unbeaten, maiden first-class fifty by Craig Miles, part of an unlikely 78-run stand for the last wicket with Graeme McCarter, had earlier ensured Klinger's side avoided following on. Tailenders Miles and McCarter were greeted first up with a hostile spell from left-arm paceman Tymal Mills, tearing in from the Ashley Down Road end, yet both showed admirable heart as well as technique.
Miles, 19, is probably only batting at No. 11 due to his tender years and he became only the sixth Gloucestershire player to make a half-century in that position with some handsome drives and sensible back-foot manoeuvring. His wicket would remain intact, the teenager cashing in on Essex's refusal to consistently pitch the ball up or introduce spinner Monty Panesar.
The hosts were eventually all out when the similarly impressive McCarter was run out by Reece Topley's direct hit from deep backward square, meaning the deficit stood at 146.
That had stretched to 178 by the start of the second session, heightening Gloucestershire's need for quick wickets to avoid being cut adrift in the contest. Instead Mickleburgh and Gambhir struck the right balance between attack and defence, the latter the first to reach 50 off 72 balls with the aid of seven boundaries.
The 31-year-old averages 44.18 from 51 Test matches and had too much class for a young attack, who are showing signs of weariness as September looms.
Mickleburgh required 116 deliveries to achieve the same feat, and six overs later Gambhir signalled the visitors' intent when he launched Benny Howell for six into the building site. A virtually identical shot by Mickleburgh yielded the same result before Gambhir reached a 141-ball hundred with a single off David Payne, and by tea Essex had amassed a huge advantage of 337 at 191 without loss.
Gambhir departed eight balls after the resumption, hooking Miles to Hamish Marshall on the square-leg boundary, having faced 149 balls and hit 12 fours and a six.
Mickleburgh holed out to the same fielder off Tom Smith in the next over and spinner Smith dismissed his namesake Greg for 40 via Alex Gidman's tumbling catch at backward point before Owais Shah was pinned leg before by Miles. Ryan ten Doeschate made 23 not out at a run a ball before the declaration came and Gloucestershire's reply started steadily.