Brentford will have to come from behind if they are to reach the Sky Bet Championship Play-Off Final after they were cruelly beaten at Griffin Park.
Middlesbrough won the first leg of the two legged tie in West London thanks to a stoppage time goal from substitute Fernando Amorebieta.
The Bees looked as if they would get at least a draw after Andre Gray had equalised in the second half. Jelle Vossen put Middlesbrough in front in the first half but they were hanging on at times after the break before Amorebieta struck at the death.
The match took a while to settle down with little of note in the first 15 minutes.
An early Alex Pritchard free kick was comfortably saved by Dimitrios Konstantopoulos and Lee Tomlin looped a header over at the other end.
Middlesbrough seemed happy to keep men behind the ball once Brentford had settled in to their regular pattern of possession football.
The visitors snapped in to challenges, often illegally, and slowed the game down.
It made it less of a spectacle but that did not concern Middlesbrough.
Konstantopoulos saved a Gray effort after he got on to a quick free kick and the Middlesbrough goalkeeper then got a fingertip to a fierce Alan Judge shot, pushing it on to the post and wide.
The game was starting to settle in to a pattern with Brentford forcing their visitors back and looking for openings.
But then Middlesbrough struck.
A Grant Leadbitter free kick was blocked but the ball was recycled on the right, Adam Clayton delivered a cross and Vossen stole in unmarked to head home from ten yards.
Judge fired a free kick over for The Bees but Middlesbrough had their tails up.
David Button got down well to save a Tomlin shot and the Brentford goalkeeper produced an even better stop from the resulting corner.
George Friend nodded it down to Vossen and the striker turned it towards goal from two yards but Button somehow got down to scoop it away.
Brentford broke quickly but Jota’s ball in to Gray was intercepted.
James Tarkowski could have levelled before the break but nodded a Pritchard free kick just over and Vossen fired off target at the other end.
Daniel Ayala missed the target with a header just after the restart but Brentford took control after the break.
Jota and Judge switched flanks and Brentford moved the ball better in the final third.
They left the door open at the back a little but the game was superb to watch as Brentford went for it.
Gray should have levelled when a Judge cross reached him ten yards out but he fired over with the goal at his mercy.
However, moments later, he made no mistake.
The striker chased a lost cause and got a lucky break when Konstantopoulos’ kick cannoned in to him, as the ball dropped, the striker rolled his 17th goal of the season home from a tight angle.
Gray almost doubled his tally when he cut inside and shot just over while, at the other end, Harlee Dean made a fine tackle when Patrick Bamford looked to be away.
Button saved from Vossen and then made a superb stop high to his left from an Albert Adomah shot.
Bamford fired in to the side netting and then forced Dean in to a block as the game became incredibly stretched.
At the other end, Konstantopoulos made a wondrous save from a looping Jonathan Douglas header to keep his team level.
Douglas had another effort blocked soon after, as did Bamford at the other end.
Vossen and Gray had efforts blocked, Pritchard fired a free kick in to a wall and Dean fired over as Tarkowski had nodded down.
Friend fired over for Middlesbrough and a Pritchard effort deflected wide as the game flowed from end to end.
Just when it looked like Brentford would have a share of the spoils, and perhaps a moral victory, to take up north, Middlesbrough struck.
Leadbitter delivered a corner, Friend nodded down and Amorebieta spun and fired a deflected effort in to the corner of the net.
Brentford still had a chance to level when a short corner was fired across goal by Pritchard, just eluding Tommy Smith, but Middlesbrough got over the line.
And The Bees know they must win the Second Leg at the Riverside Stadium next week if they are to have any chance of reaching the Sky Bet Championship Play-Off Final.
Brentford: Button; Odubajo, Dean, Tarkowski, Bidwell; Douglas, Diagouraga; Jota (sub Dallas 77 mins), Pritchard, Judge (sub Smith 88 mins); Gray
Subs (not used): Bonham, Craig, Macleod, Toral, McCormack
Bookings: Judge (31 mins) (ninth of season), Tarkowski (46 mins) (eighth of season), Bidwell (89 mins) (eighth of season)
Middlesbrough: Konstantopoulos; Whitehead, Ayala, Gibson, Friend; Adomah, Clayton, Leadbitter, Tomlin (sub Amorebieta 73 mins); Vossen (sub Forshaw 82 mins), Bamford (sub Kike 90 mins)
Subs (not used): Ripley, Reach, Omeruo, Nsue
Bookings: Tomlin (15 mins), Friend (17 mins), Adomah (40 mins), Whitehead (41 mins), Amorebieta (76 mins), Forshaw (85 mins)
Attendance: 11,691 (1,452 away fans)
By Chris Wickham