Essex 356 (Foster 143, Pettini 72, Hoggard 6-66, Wyatt 3-80) and 161 for 6 (Foster 42, ten Doeschate 37*, Wyatt 3-35) beat Leicestershire 302 (O'Brien 67, Napier 7-90) and 214 (Naik 47*, ten Doeschate 4-18, Topley 3-51) by 4 wickets
Essex's topsy-turvy Championship season continued with a battling four-wicket win against Leicestershire in their LV= County Championship Division Two clash at Grace Road.
Ten days after the humiliation of being bowled out for 20 by Lancashire, it was a nervy and edgy victory by Essex, who scrambled over the line with 3.4 overs to spare.
But it kept their promotion hopes alive, leaving them 17 points off a promotion place.
Chasing a target of 161 in 40 overs, Essex slipped to 79 for 5 in the 27th over and it needed a 66-run stand between Ryan ten Doeschate and James Foster to put them back on track.
After seeing their victory bid initially held up by Leicestershire's tail-enders, Essex made a dreadful start to the chase losing their first two wickets for 13 runs in five overs.
Jaik Mickleburgh was lbw to Alex Wyatt offering no shot and Matthew Hoggard trapped Nick Browne plumb in front.
It became 34 for 3 when Owais Shah, whose return to Championship cricket has brought little benefit so far, edged Wyatt to wicketkeeper Niall O'Brien and Tom Westley fell in the same fashion. And when Mark Pettini drove a catch to cover off Ollie Freckingham the alarm bells were jangling.
But Essex counterattacked vigorously. Foster and Ten Doeschate put on 66 in eight overs with Foster making 42 off 27 balls before popping up a catch to mid-wicket.
By then Essex were just about home and dry, and Ten Doeschate, with an unbeaten 37, and Graham Napier (13) saw them to the win that earned 23 points. Wyatt claimed 3 for 35 in 13 impressive overs for the hosts, who take six points from the match to remain two points above the bottom club Kent.
Leicestershire began the final day at 91 for 4, leading by 37 runs, and when Shiv Thakor and Matt Boyce were out to successive deliveries with only 18 runs added, it suggested there could be a quick finish to the game.
Thakor nicked a catch behind off the last ball of a Napier over and Reece Topley trapped Boyce lbw with his first delivery.
At one stage it looked likely Essex could be batting before lunch. Instead, with Jigar Naik leading the way, Leicestershire's last two wickets added another 79 runs in 33 overs spread over two hours.
Naik and Hoggard, who made 24 off 73 balls, shared a stand of 43 in 21 overs. Then Naik was joined by Wyatt in a last-wicket partnership worth 36 in 12 overs.
Wyatt was finally out lbw to Topley for 17, leaving Naik unbeaten on a season's best 47 off 141 balls. Ten Doeschate claimed 4 for 28 and Topley 3 for 53.
It was a long haul - but Essex were not to be denied.