Daryl Murphy scored a late winner at Griffin Park, where Brentford were desperately unlucky to lose.
Dwight Gayle opened the scoring before Lasse Vibe equalised and then almost put the Bees ahead.
The home side were on top when, with 10 minutes remaining, Ayoze Pérez served up a superb cross for substitute Murphy to head home.
Newcastle’s win took them back to the top of the Championship.
Gayle struck for them on 20 minutes, when he raced down the left after beating the offside trap and walloped a shot beyond keeper Daniel Bentley.
Striker Gayle went off injured eight minutes later but the Magpies continued to have the upper hand.
They would have doubled their lead had Bentley not denied Pérez from close range after the Spaniard had exchanged passes with Yoan Gouffran.
But Brentford responded and keeper Karl Darlow twice denied Vibe, first after the Dane had been put through on goal and then after he had been set up by Nico Yennaris, who fired wide in the final minute of the first half.
Brentford continued to press after the interval and were rewarded when Vibe scrambled in the loose ball after Darlow had produced a brilliant save from Andreas Bjelland.
Brentford were then very unfortunate not to take the lead.
Harlee Dean headed just wide from Ryan Woods’ corner and they went even closer when Vibe lobbed Darlow only to see his effort hit the post and roll along the line before being cleared.
Having earlier lost Gayle, Newcastle suffered two more injury blows.
Isaac Hayden had to be replaced by Vurnon Anita, who was stretchered off 10 minutes after coming on following a challenge by Maxime Colin.
Rafael Benitez’s side seemed to be struggling, but out of nothing they conjured up a brilliantly-worked second goal.
They then had to withstand a barrage of pressure and were fortunate not to have a penalty awarded against them when Philipp Hofmann had his shirt pulled in the area.
Vibe went close to equalising and Jota, on as a substitute, saw an effort saved by Darlow in injury time.
Brentford: Bentley, Colin, Dean, Egan (Hofmann 88), Bjelland, Yennaris, McEachran (Jota 80), Woods, Sawyers (Clarke 90), Field, Vibe.
Subs not used: Bonham, Hogan, Kerschbaumer, Barbet.
This post was last modified on 14/01/2017