Arsenal took the lead on 14 minutes when Alexandre Lacazette scored from Pierre-Emerick Aubameyang's cross.
But Newcastle responded well and Ayoze Perez nipped in at the near post to equalise from DeAndre Yedlin's centre 15 minutes later.
Substitute Islam Slimani helped set up Newcastle's winner when Arsenal could not clear their lines; his header was touched on by Perez and Ritchie was on hand to smash the ball home.
Newcastle went close to extending their lead but Kenedy's shot was deflected onto the crossbar.
A fourth league win in a row puts Newcastle on 41 points, 13 clear of the bottom three, while Arsenal remain sixth, six points behind Chelsea.