© Getty Images
The Rams controlled the opening stages and almost took the lead with five minutes on the clock as Simon Dawkins surged into the Bees box and fired a shot into the side-netting.
Derby turned their dominance into a goal in the 26th minute when Craig Forsyth's measured cross was turned in off the post by Martin, whose tally for the season now stands at 12.
The Coldplay frontman's namesake almost had a second just after the half-hour mark, but his flicked effort was saved by David Button as Brentford kept their deficit at one come the interval.
Derby continued to ask most of the questions, but it was Brentford who came close to a second in the 68th minute when Alan Judge's cross was headed against the post by Gray from close range.
Just as the match looked to be heading for a draw, the Bees snatched all three points in stoppage time as Stuart Dallas lashed a strike into the top corner to knock Derby off their Championship perch.