
Tom Cairney headed Fulham level with his second goal of the season
Fulham fought back superbly to end Brentford's four-match winning Premier League run and keep alive their slim hopes of qualifying for Europe next season.
The visitors needed victory to stand any chance of securing an eighth-placed finish in the top flight.
And they took a deserved lead when Raul Jimenez rose above Nathan Collins to power a header past Mark Flekken from Adama Traore's cross.
But Brentford were level just six minutes later when Bryan Mbeumo dispossessed Traore inside the Fulham half before collecting Yoane Wissa's in his stride and arrowing a low shot into the far corner.
The forward then had a penalty saved by Fulham goalkeeper Bernd Leno, but the Bees completed the turnaround two minutes before half-time when Wissa tapped home Christian Norgaard's knock-down on the line after Fulham had failed to clear Michael Kayode's long throw.
Chances were few and far between after half-time until midfielder Tom Cairney – out of contract in the summer and linked with League One runners-up Wrexham – glanced a 68th-minute header into the far corner.
The visitors were not done, though, as Harry Wilson - whose stoppage-time goals earned the Cottagers all three points in the reverse fixture - curled a sensational strike into the bottom corner to complete the comeback and set a new record Premier League points tally for Fulham.
Reflecting on another eventful home game, Brentford boss Thomas Frank told BBC Match of the Day: "It's not the Gtech [Community Stadium], it's the 'Goal-tech' now!
"We could have been out of sight. We missed a penalty and created other good situations and a lot of chances. It was very even in the second half, it's not a half we should lose 2-0.
"I'm a strong believer that if we play that game again, we would win it."
The defeat left Brentford in eighth place, but just one point ahead of 10th-placed Fulham.
Cottagers show spirit to land notable league double
Silva thinks captain Cairney will be with Fulham next season
Fulham host Manchester City on the final day of the season, but Brighton can end the Cottagers' hopes of an eighth-place finish on Monday if they beat champions Liverpool at Amex Stadium.
Had City beaten Palace in the FA Cup final on Saturday and gone on to finish in the top six, the team that came eighth would have qualified for next season's Uefa Conference League.
However, that team will now need Chelsea to finish seventh and beat Real Betis in this season's Uefa Conference League final on 28 May to clinch a place in the competition.
Speaking before the game, Fulham manager Marco Silva had called on his players to show a reaction to last weekend's poor second-half performance at home to Everton, who triumphed 3-1 to inflict a fourth defeat in five games on his team.
The combination play between Traore and Jimenez caused Brentford plenty of problems as they made a bright start, with the Mexican twice going close to giving them an early lead before his header squirmed under Flekken.
While Silva will be frustrated with the manner of the Bees' first-half goals, he will be thrilled with his team's response against a side who had lost only two of their last 12 top-flight games.
Club captain Cairney, who had replaced Sander Berge at half-time, celebrated wildly in front of the away end after nodding the Cottagers level with only the 34-year-old's second league goal of the campaign.
"I know very well what Tom can give us," Silva told BBC Match of the Day. "I know what he can do.
"He made a massive impact. With him on the pitch and on the ball, we are at peace."
Fulham fans were soon celebrating again when Wilson's left-footed drive found the bottom corner, earning the visitors their first league double over their London neighbours since 1947-48.
Bees fade after impressive first half
Frank 'fuming in every way' after loss
In-form Brentford had looked set to five consecutive top-flight victories for the first time since 1939 after Mbeumo and Wissa struck their 19th Premier League goals of the campaign before the break.
But the hosts faded as an attacking force after the restart, failing to another attempt at goal until the 74th minute, by which time Fulham had already regained the lead.
The closest they came to another equaliser was when Norgaard's 86th-minute header was tipped over the crossbar by Leno, who had crucially denied Mbeumo from the spot in the first half.
The in-form Cameroon forward had scored his previous 11 penalties for the Bees, but Leno dived the right way to keep out his latest effort.
Only Manchester City, Newcastle, Arsenal and Liverpool have scored more goals than Brentford this season, but their defensive record on home soil leaves a lot to be desired.
Relegated Southampton and Ipswich are the only sides to concede more than the Bees' 35 in front of their own ers – the most Brentford have shipped at home in the top flight since 1946-47.
Frank's men must now beat Wolves at Molineux on the final day of the season and hope other results go their way to stand any chance of sneaking into Europe.
"Even if we finish top 10, it is an unbelievable performance from this club and this team," added the Bees boss.
"We will do all we can to win at Wolves. Everything is still on."
Player of the match
After the opportunity to rate players has closed, the score displayed represents the average from all the submissions by BBC Sport s.