Paceman Clint McKay took 4-37 for match figures of 8-84 as Essex were bowled out for 133 in their second innings.
It left the visitors with a victory target of 159 from 33 overs.
Opener Angus Robson made 56 off 75 balls, his second half-century of the game, as they stuttered home on 159-6 with just 11 balls to spare.
Essex began play on 22-1 and lost three wickets during a morning session which also saw a lengthy hold-up for bad light.
Tom Westley was lbw to Rob Taylor for 25 straight after lunch, and that proved to be the highest score in a disappointing Essex effort, in which their last five wickets went down for 32 runs.
It looked plain sailing for the visitors as Robson and Mark Cosgrove (38) added 53, but they both departed in the space of four overs before Neil Dexter finally hit the two runs needed at the start of the penultimate over to secure their second win of the summer.
Division Two leaders Essex suffered their first Championship defeat of the season as Leicestershire edged home by four wickets at Chelmsford.