Lancashire 177 (Phillips 3-20) and 253 for 7 (Prince 80, Brown 80, Topley 5-80) beat Essex 226 (Napier 102*, Procter 4-66) and 203 for 3 dec (Cook 60, Mickleburgh 53*) by three wickets

Sajid Mahmood may have pictured a triumphant homecoming on his return to Old Trafford with Essex, who he joined following an acrimonious departure from Lancashire during the winter, but instead he suffered a final day that will haunt him for many years to come.

The stage was set for Mahmood, furious that Lancashire were not prepared to offer him a new contract at the end of last season, to deny his former team a thrilling victory as they attempted to chase down 253 off 51 overs on the final afternoon. That target was later reduced by four overs by an interruption for bad light, but it was Mahmood's intervention that proved decisive.

Given the responsibility to bowl the 44th over of the innings, with Lancashire needing 32 to win off the final four overs, it was pretty much the turning point of the match as Steven Croft helping himself to 15 off the final five balls, including a six over midwicket and an all-run four through the covers.

If that was not enough of a setback for Mahmood, he was to play an even bigger role in the final over, with Lancashire needing five runs to win having lost three wickets in the previous over. They scored four off the first four deliveries before Wayne White launched Graham Napier to Mahmood at long leg, only for him to spill the regulation catch and allow the single to be scrambled that secured victory.

"When we saw that last ball, we all ended up with mixed feelings," said Karl Brown, whose 80 in a 169-run stand with Ashwell Prince proved crucial to Lancashire's win. "Saj is a great mate of a lot of the lads, we've played with him for a long time and it's not nice to see that happen. We won the game so we were really happy, but I think we all spared a thought for Saj because that's not nice when that happens, especially to someone you're so close to."

Lancashire's triumph came a week after they dismissed Glamorgan for 139 at Colwyn Bay chasing 154 for victory and boosts their promotion hopes. That the umpires saw fit to dock each side a point for slow over rates was barely noticed in either dressing room after such a compelling advert for county cricket.

Essex, in particular, deserve plenty of credit for their role in such an exciting finale. Having reached 203 for 3 overnight and in little trouble, they could have watched from the dressing room for the final afternoon and enjoyed batting practice in the middle.

Instead they set up a game to remember and so nearly secured an astonishing win themselves. They began the final afternoon impressively, dismissing both Lancashire openers in the space of three balls to leave them struggling on 13 for 2. Despite an outstanding opening spell from Reece Topley, and Mahood troubling Lancashire's batsmen with his pace and bounce, Essex could not dislodge Brown and Prince during their 198-ball partnership.

Both fell in quick succession for 80, Prince bowled by Topley making himself room and Brown in similar fashion to Napier, only for Steven Croft and Simon Katich to add 41 in four overs to leave Lancashire needing 12 off the final two overs.

Just as victory was in sight, Topley responded by claiming three wickets in an over to finish with 5 for 80, with Croft falling to a brilliant diving catch from Rob Quiney in the deep that forced him off the field with a shoulder injury.

It left Lancashire facing a tense final over, which was finally settled by Mahmood's misfield, and left Essex rueing missed opportunities. "We took a bit of a punt, but the way we'd been playing, showing a lot of character and skill, we thought it was an excellent opportunity to get a win under our belts and get a lot of points," captain James Foster said. "It was a risk but we thought it was a calculated risk."