Shola Ameobi scored his third goal of the season as Newcastle handed Harry Redknapp his first defeat as Queens Park Rangers manager.
It looked like being a frustrating day for the Magpies, who had lost six of their previous seven games, as Demba Ba and Papiss Cisse missed good chances.
But substitute Ameobi rifled in a shot with nine minutes remaining for his first league goal in nine months.
QPR battled hard, with striker Djibril Cisse missing their best chance.
Rangers, who defended stoutly and looked dangerous on the counter-attack, thought they had done enough as they looked to continue their mini-revival under new manager Redknapp.
However, it was Redknapp's opposite number Alan Pardew who changed the course of the match, with two of his substitutes having a direct influence in the match-winning strike.
Sylvain Marveaux replaced Cheick Tiote with 13 minutes left, and his extra quality created the opportunity for Ameobi to collect the Frenchman's pass, cut inside and find the back of the net with a classy finish.
It justified Pardew's decision to replace Papiss Cisse with Ameobi - a substitution which caused some discontent from the stands, and plenty of frustration from the Senegalese striker. Papiss Cisse refused to shake his manager's hand as he angrily made his way to the dugout to watch the remainder of the match.
It capped a miserable day for the number nine, as he and his strike partner Ba struggled to break down a resolute Rangers defence expertly marshalled by Ryan Nelsen.
The one time the two did link up to good effect midway through an uninspiring first half ended with Cisse being denied by Fabio's well-timed tackle.
Ba also fired two free-kicks into the stands as Newcastle looked short on ideas without influential midfielders Yohan Cabaye and Hatem Ben Arfa.
QPR almost stunned St James' Park after the break when Adel Taarabt, who scored two goals in his side's victory over Fulham last weekend, showcased some outrageous skill to leave three defenders in his wake and slotted a pass through for Djibril Cisse. The French striker held off his marker, but his shot found the side-netting.
Newcastle were struggling for inspiration, until Pardew brought on Ameobi and Gabriel Obertan with just half an hour to go.
The change worked a treat, as the home side became much more of a threat in the final third - Ba turning and having a shot deflected over and then having a weak header saved by Rob Green.
A goal seemed inevitable, and it was no surprise when Ameobi slotted home. There was still time for the impressive Marveaux to go close with two shots that were well saved by Green, but Newcastle had done enough.
The only negative to come out of the game for the hosts was a fifth booking of the season for Tiote, which rules the midfielder out of his side's Boxing Day trip to Manchester United.
Rangers will take plenty of heart from their workmanlike performance, with defeats for their relegation rivals Reading, Wigan and Southampton meaning very little has changed in the bottom four.
Newcastle boss Alan Pardew: "I know the crowd weren't particularly pleased when I took Cisse, a goalscorer, off but I just felt Shola, he's a big man and this was a big occasion and he likes big occasions.
"It said QPR on the programme but really it was bigger than that, I think we all knew that and he has that calm head - he knows what is demanded here - to produce a quality goal, and it won us the game.
"I wanted to get Shola on the pitch, and thank goodness I did because it was a really class finish."
QPR boss Harry Redknapp: "I thought we were going to hang on and nick a draw. I couldn't see us winning, but we just couldn't see it through.
"I thought we could hang on for a good point to keep us going, but it just wasn't to be."