Brentford guaranteed at least a place in the play-offs and stayed in the hunt for automatic promotion with a 3-1 win at Derby, who suffered a blow to their top six hopes.
Ollie Watkins scored his 24th goal of the season to give Brentford an early lead but Derby hit back strongly to level through Jason Knight, only for a Ben Hamer howler to change the game.
The Derby goalkeeper should have saved Said Benrahma's low drive early in the second half but allowed it to go under him and the winger sealed victory with his second in the 64th minute – a sublime shot from the edge of the box.
Derby kept going but the defeat leaves them three points off sixth spot while Brentford move to within two points of second place, courtesy of their seventh win in a row.
Both teams needed the points to keep their ambitions alive and Brentford made a great start with a goal in the third minute.
Derby were opened up on the left and after Bryan Mbeumo's shot came back off a post, Watkins tapped in the rebound.
Brentford went close again in the 11th minute when Mbeumo had a shot blocked by Matt Clarke while Derby responded by forcing a corner which broke to Max Bird on the edge of the area but he fired wide.
Derby threatened in the 20th minute when Louie Sibley burst forward and Chris Martin hit a 25-yard shot which David Raya parried before holding onto.
The momentum had swung towards the home side and Derby equalised in the 29th minute when Wayne Rooney slipped the ball in to Knight who shot across Raya and inside his right post.
Brentford had lost some of their poise and Derby broke quickly in the 36th minute, with Sibley firing an angled shot over.
Benrahma had a shot easily saved in first-half stoppage time but Derby had come back into the game well after Brentford's fast opening.
But Brentford began the second period with another incisive move that saw them regain the lead in the 49th minute with, Hamer at fault.
The ball was worked across to Benrahma who shot from just inside the box and it squeezed under Hamer and over the line.
Hamer was beaten again in the 64th minute but this time he could do nothing as Benrahma went past two defenders on the edge of the box before curling a right-foot shot into the top corner.
Derby had to reply quickly and Knight had another chance in the 71st minute when Martin played him in but this time his shot was straight at Raya.
Both teams had penalty claims dismissed as the game moved into the closing stages but after that Hamer error, it had been comfortable for Brentford.