Michael Keane fired home a dramatic stoppage time equaliser to preserve Burnley’s four-month unbeaten run and a top two spot.
A Jordan Rhodes goal 21 minutes from time looked to have settled a frantic encounter for the visitors, who had scored injury time winners in three of their previous six games.
But the boot was on the other foot as, following a sustained late spell of pressure, Keane stabbed home Matty Taylor’s corner in the 92nd minute to extend their unbeaten run to 20 games and send Turf Moor into meltdown.
Brighton’s win over QPR edged the south coast side level on points with Sean Dyche’s men, with both teams just two shy of Boro.
But with the Clarets still second on goal difference with just three games remaining, the promotion race now seems certain to go right to the wire.
Burnley were unchanged from the side that sealed back-to-back wins with the weekend win at Birmingham.
However, a knock to defender James Tarkowski, who played a vital late role at St Andrew’s, led to a recall to the bench for Michael Duff.
We expected a tasty tussle and Grant Leadbitter lit the fuse within 60 seconds with a crunching late challenge on Joey Barton that earned the Boro skipper a yellow card.
Three quick corners for the hosts soon ramped up the atmosphere another notch, but it was Boro who came close to breaking the deadlock in the 13th minute.
Stewart Downing’s deep corner was only half cleared to Albert Adomah, whose fierce rising effort clipped the top of the crossbar.
And from a whipped Gaston Ramirez cross soon after, a diving Rhodes beat the inrushing Adomah to the ball, only to head tamely wide.
As the frantic start continued, Barton fired just wide from distance, before Gray hooked Sam Vokes’ knock down wide of goal.
And there was a big chance for Burnley as the half hour approached, with Vokes taking down Heaton’s long ball and feeding Gray.
The Championship player of the year in turn spotted Scott Arfield unmarked on the left of the area, only for the Canadian to skew his snatched shot over.
These two heavyweights continued to slug it out, but half time arrived with no further incidents of note as everyone took a breather.
George Friend limped out of the action 10 minutes after the break as the pace slowed at the start of the second half.
But the first chance of note fell to the visitors, as Downing’s deep cross was miscued by Adomah as he lurked on the far post.
At the other end, Barton couldn’t keep his header down from an outswinging corner, just past the hour.
But in the 70th minute, the deadlock was finally broken.
Ben Mee was penalised for a petty foul on Rhodes and from the resulting free kick, the £9m January signing toe-poked past Tom Heaton from a knock-down to grab the crucial opener.
Vokes headed a Lowton cross over as the hosts looked for a quick response.
And following good work from Barton, Boyd’s shot was blocked in the six-yard box by sub Ritchie De Laet.
With Lloyd Dyer already on for Arfield, Ashley Barnes replaced Gray with 10 minutes remaining as Burnley pushed.
And Boro had a late let off when Matty Taylor’s free kick, with virtually his first kick, was deflected just wide of a wring-footed Dimi Konstantopoulos’s right hand post.
As they rocked, the visitors somehow survived as Barnes spun onto a loose ball, but saw his goalbound effort somehow deflected over.
But the reprieve was short lived as Taylor’s corner caused mayhem and Keane, scorer of an injury time equaliser recently at Brighton, swept the ball home gleefully at the far post.
Burnley: Heaton, Lowton, Keane, Mee, Ward, Boyd (Taylor 83), Marney, Barton, Arfield (Dyer 75), Vokes, Gray (Barnes 80).
Subs: Robinson, Duff, Darikwa, Jones
Booked: Marney 26
Middlesbrough: Dimi, Nsue, Ayala, Gibson, Friend (De Laet 54) Clayton, Leadbitter, Adomah, Ramirez (Forshaw 75), Downing (Kalas 90), Rhodes
Subs: Agazzi, Nugent, De Sart, De Pena,
Booked: Leadbitter 1, Clayton 58
Ref: M Jones
Att: 20,197 (2,401)