Sergio Aguero rolled home to give City a first minute lead on Tyneside, applying the finish to David Silva’s headed assist and leaving the hosts with a sizeable task ahead of them.
But Salomón Rondón – whose goals have proved vital for the Magpies this term – levelled matters after the break, steering home with a third of the game still to play.
And ten minutes from time, Rafa Benítez’s side completed a memorable turnaround as Ritchie slammed home from the spot after Sean Longstaff was hauled down by Fernandinho.
The victory – their second league win in succession – lifts Newcastle up to 14th in the table ahead of Saturday’s trip to Tottenham Hotspur.
That Aguero strike came just 25 seconds into the contest. Silva’s looping pass freed Raheem Sterling, who cut inside and shot. It was blocked, though, with the deflection looping kindly for the Spaniard at the far post. He beat Martin Dúbravka to the ball, nodding it back into the path of Aguero, who dispatched with ease.
United battled on despite that early setback and, while City predictably looked to move the ball with speed, the hosts pressed. Ayoze Pérez forced an error from Danilo, but could only drag his shot wide after gathering the loose ball.
Though the champions couldn’t find their devastating fluency in attack after their opener, they constantly kept the Magpies’ backline busy. Kevin De Bruyne whipped a quickly-taken free kick behind the defence for Aguero to sweep home but saw it chalked off by referee Paul Tierney, who proceeded to book the Belgian.
Benítez’s men remained disciplined and Christian Atsu saw a shot diverted over, but in the half’s dying moments they almost went two behind. Danilo’s cross was meant for Leroy Sane but the ball ran loose for Silva. He stooped to head home, but was denied by Fabian Schär, who stuck out a leg a yard from goal to keep it out.
Three minutes after the restart, and more City pressure. Silva sidestepped a challenge in the box and fed Sane, whose inviting centre was missed altogether by Sterling with Ritchie snapping at his heels. Then another chance, this time for Silva, who drove straight at Dúbravka after peeling away from his man in the area.
De Bruyne was fortunate to escape a second caution after his late lunge felled Ritchie on the hour – just a few moments before Pep Guardiola brought Bernardo Silva on in his place – but from there, Newcastle rallied. Isaac Hayden headed it high over the City defence and when the ball dropped, Rondón was there, bouncing his volley into the turf and beyond Ederson to bring St. James’ Park to its feet.
With less than 25 minutes remaining and the scores level, Guardiola threw on Gabriel Jesus. He won a free kick by the corner flag which was rolled across to the unmarked Danilo, and his powerful strike – which was on target – struck his teammate John Stones on its way through the crowd of bodies.
But at the other end, with black and white shirts probing them at every turn, City faltered. Fernandinho was robbed in his own box by young Longstaff, and the Brazilian brought him down as he looked to shoot. Tierney pointed to the spot, Ritchie stepped up and – with no hesitation – belted Newcastle into an 80th minute lead.
It was no less than the unflappable Longstaff and the tireless Ritchie deserved, but there was still 15 minutes remaining; there was further pressure to withstand and five additional minutes to navigate.
But United did so with discipline, thoroughly meriting the raucous reception they received from the stands after their finest result of the campaign so far and one which will live long in the memory.