Bopara (left) and Cook have both struggled for form in the Ashes series
Alastair Cook and Ravi Bopara found form ahead of the fifth Ashes Test as they hit half-centuries to lead Essex to a five-wicket win over Middlesex.
With Essex needing 241 to win from a minimum of 45 overs, Cook (66) and Bopara (52no) helped the visitors get home with two overs to spare.
Earlier, Middlesex slipped to 59-5 after being 47-3 overnight.
But Dawid Malan (87no) helped guide the hosts to 229-7, before a sporting declaration set up the Essex chase.
The game looked to be heading for a draw after Malan and Ben Scott (44) added 99 for the sixth wicket, until, soon after the lunch break, acting Middlesex skipper Eoin Morgan struck a deal with Essex counterpart Mark Pettini.
Middlesex might be second bottom of Division Two, but victory would have lifted them within realistic reach of the promotion-chasing pack.
As it was, Essex were the ones to take advantage.
Pettini himself conceded 24 runs from just five deliveries, as the hosts were fed runs to hasten the declaration, before promoting himself to open the Essex batting as a pinch-hitter.
He and Cook added 100 in 66 minutes either side of the tea interval, before both men fell, to Tim Murtagh and Murali Kartik respectively, in quick succession.
With 112 needed from the final 15 overs, Bopara anchored the innings, allowing Ryan ten Doeschate to club 40 from 20 deliveries and bring Essex within sight of their third victory of the season.
The Dutchman was bowled by Kartik, and James Foster followed soon after.
But Graham Napier hit the winning runs to see the visitors home with 12 balls to spare - to take them within 21 points of the second promotion place.
Essex captain Mark Pettini told BBC Essex:
"I was going off to have some treatment when they asked me if I wanted to sort something out.
"I went over to speak to their guys and in the space of about five minutes we managed to set a game up.
"We were always going to need a few big overs and we played very well against a world-class spinner."
Middlesex coach Richard Scott told BBC London 94.9:
"The turning point was our first 10 overs at them, when we bowled too short at Cook and then Ryan ten Doeschate came in and played a superb innings.
"And the lads can hold their heads high. We played all the cricket in this game and we were the only side prepared to risk losing to try and win.
"When their captain came off, he talked to Eoin Morgan about what it might take to set up a game and we decided that 241 in 45 was fair.
"But, at the end of the day, we're not going to climb the league by drawing games so it was a positive move."
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.