Manchester United s English striker Marcus Rashford (R) celebrates after scoring his team first goal during the English Premier League football match between Manchester United and Brentford at Old Trafford in Manchester, north west England, on April 5, 2023. AFP
Callum Wilson and Joelinton each scored twice for the Magpies, who remain above United on goal difference.
Both sides now have a three-point lead over Tottenham and a game in hand over Spurs in the race for a place in next season's Champions League.
United had slipped to fifth after a run of three league games without a win and cup commitments that meant they had not registered a Premier League win since mid-February.
Erik ten Hag's men also had a score to settle with the Bees after a humiliating 4-0 defeat when the sides last met in August.
The Dutch coach was stinging in his criticism of his players' attitude and desire in losing 2-0 to Newcastle on Sunday and got the response he was looking for.
In stark contrast to recent matches, United started brightly and could have been in front before Rashford's strike as Anthony and Scott McTominay fired just off target.
Rashford started through the middle as Ten Hag's patience with Wout Weghorst finally ran out and that decision bore fruit when the England international was perfectly placed to side-foot home Marcel Sabitzer's knockdown for his 28th goal of the season.
Brentford had lost just one of their previous 16 Premier League games to rise to ninth in the table.
Thomas Frank's men had offered barely anything of an attacking threat for the first hour but were nearly gifted an equaliser when Ivan Toney charged down David de Gea's clearance and the ball flew inches wide.
De Gea made amends when he spread himself to block from Kevin Schade with Brentford's only other clear sight of goal.
A fourth consecutive win edged Newcastle closer to the Champions League for the first time in 20 years.
Wilson was restored to the starting line-up by Eddie Howe in place of Alexander Isak and rewarded his manager's trust by heading home the opener after just six minutes.
Joelinton doubled the Magpies lead inside 13 minutes as the Brazilian latched onto Fabian Schar's ball over the top and coolly rounded Lukasz Fabianski before slotting into an empty net.
Kurt Zouma's header just before half-time briefly gave West Ham hope.
But within seconds of the second half kick off. Nayef Aguerd was dispossessed inside his own box by Jacob Murphy, who squared for Wilson to have a tap in.
Another West Ham gift allowed Isak to make it four as Fabianski cleared the ball into the Swede's path before Joelinton delivered the final blow.
David Moyes looked on aghast at his side's defending it could the final nail in the coffin for the Scot as he faces becoming the 13th Premier League manager sacked this season.
Defeat leaves the Hammers still out of the relegation zone only on goal difference.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)
Short link: