Yorkshire 50 (S Cook 5-28, Siddle 4-7) and 329 (Brooks 124, Bairstow 50, Siddle 4-65) beat Essex 142 and 146 (Patterson 6-40) by 91 runs
Steve Patterson, who claimed a career-best, and Ben Coad tore out four Essex wickets for no runs in the space of 23 balls to set up one of the most incredible comeback victories in County Championship history.
Essex had started the day requiring 141 to reach their 238-run target with six wickets standing. The end came at 12.30pm, half an hour before lunch, with Essex still 92 runs short.
It was a remarkable turnaround in the fortunes of Yorkshire, who almost exactly 48 hours earlier had been all out for a humiliating 50 in little more than 18 overs. It became the sixth-lowest first-innings total to win a Championship match.
It was Essex's first defeat in the Championship for 20 months, spanning 19 games, since they lost at Chelmsford to Glamorgan in the match that confirmed their promotion to Division One. Yorkshire took 19 points for their win to Essex's three.
Yorkshire's second victory of the season was sparked by Jonny Bairstow, who elevated himself to open the second innings after tea on the first day and thrashed 50 in double-quick time to alter the destiny of the game, and then set up by Harry Brook's maiden first-class hundred.
It was finished by Patterson who claimed career-best figures of 6 for 40, beating the 6 for 56 he took against Durham in June 2016, the last time he had a five-wicket haul.
"It was a really difficult first day for us. The first session was probably the worst session of cricket I've ever been involved in," Patterson said. "But I thought the courage and the belief we showed from that moment on, for the rest of the game, was pretty impressive. A lot of people stood up at tough times and made important contributions and thankfully several days later we're celebrating victory.
"It's hard to win four-day games no matter who it's against, so you've got to savour the victories. From where we were in the game nobody would have backed us to be where we are now.
"But the one thing about Yorkshire in all the days I've been in the side is we've got tremendous belief and we've got some fantastic talent in the dressing room. We know if we truly believe and stick together you can achieve anything in the game. And that's shown in the last two days."
Coad broke Essex's resistance after 25 minutes of play when he dismissed Ryan ten Doeschate and followed with the wickets of James Foster and Simon Harmer in the space of 11 of his own deliveries.
Patterson had rattled through the first Essex four wickets on the second evening, and sent back the man upon whom Essex's hopes rested, Dan Lawrence, to claim his fifth of the innings. At that stage the county champions had lost four wickets in 23 balls with the score stuck resolutely on 114.
England Test captain Joe Root bowled the first over of the day from the River End and almost had Lawrence lofting airily to extra cover where the ball eluded two converging fielders. However, Lawrence calmed down after that rush of blood and brought up Essex's hundred two balls later.
ten Doeschate, who had cut Patterson for a thumping four, was the first in the procession after helping Lawrence to negotiate the first seven overs without concern. The pair had put on 59 in 23 overs, lifting Essex from 55 for 4 before Coad got one to keep low and had the Essex captain lbw for 34.
James Foster lasted just three balls before Coad nicked his outside edge and Bairstow, standing up, took the catch. Simon Harmer became Coad's third victim when he played over a delivery and went 1bw.
Lawrence's 100-ball stay for 32 ended when Patterson removed his middle stump as he played around a straight one. Peter Siddle and Jamie Porter put on a dozen runs for the ninth wicket before Porter became the latest lbw victim and Patterson's sixth. Siddle was the final wicket to fall of an extraordinary match when Tim Bresnan trapped him in front.