Alexandre Lacazette had volleyed the visitors into a 14th-minute lead at St James' Park, but Ayoze Perez drew Newcastle level (29) with a smart near-post finish before Ritchie completed the turnaround with a 68th-minute strike.
A fourth straight Premier League win means Rafa Benitez's once relegation-threatened side have surpassed the 40-point safety mark set by their manager and, after a priceless victory on the eve of his birthday, will now harbour real hopes of a top-10 finish.
But sixth-placed Arsenal - much-changed after their midweek trip to Moscow - have now suffered five successive defeats on the road and see their lead over Burnley trimmed to just two points with five league games remaining.
The Gunners had enjoyed a 10-match-winning Premier League streak against their hosts and had an early chance when Lacazette - playing alongside Pierre-Emerick Aubameyang for the first time - swivelled to craft space but scuffed his shot.
Jonjo Shelvey had lofted several threatening balls forward but it was a fine long drive from Shkodran Mustafi that yielded first reward, Aubameyang taking a controlling touch before crossing for a lunging Lacazette at the back post.
The hosts were struggling to find attacking rhythm as Arsenal bristled with intent, Alex Iwobi jinking in the box and drilling low before Jamaal Lascelles was forced to turn a dangerous Calum Chambers cross behind.
But Newcastle were level just before the half-hour mark when their tactic to go over the top paid off. Dwight Gayle brought down Shelvey's looping punt and when DeAndre Yedlin whipped in, Perez darted past Mustafi to sweep beyond Petr Cech.
Arsenal might have restored their lead had Lacazette, having dispossessed Mo Diame, opted to shoot rather than tee up an off-guard Joe Willock (43) but the hosts instead had a foothold and Perez broke promisingly soon after the restart before being crowded out.
Gayle, full of running, was replaced by Islam Slimani, and it was the substitute's fine header that allowed Ritchie - via a Perez flick - to bury what would prove a decisive second.
Wenger had brought on Danny Welbeck for Willock just moments before the game swung away from his side but the deficit might have been greater as Kenedy hit the crossbar just minutes later.
Newcastle withstood a late barrage into the box but the equaliser never came and the famous Geordie folk song 'Blaydon Races' rang out around the ground, Benitez's side now 13 points clear of the drop zone and surely safe.