Rafael Benitez's side led 2-0 thanks to a Ben Mee own goal and Ciaran Clark's header, but Sam Vokes hit back for the host before half-time.
Ritchie looked set to make sure of the points early in the second half but the winger, who had set up Clark's goal, bizarrely slotted wide at the back post after DeAndre Yedlin beat Charlie Taylor for pace.
But Newcastle held on for its first top-flight win over Burnley since 1975 to move up to 13th in the table, while a fourth loss in five league games leaves the Clarets still a point and a place above the relegation zone.
Kick-off was delayed for half an hour due to a medical emergency in the tunnel, but Newcastle made a rapid start and opened the scoring in the fourth minute.
Burnley did not properly clear a corner and, when Federico Fernandez took aim, his 25-yard drive - which was heading wide of the post - beat Joe Hart via a deflection off Burnley captain Mee.
And the visitor's lead was doubled in the 23rd minute with the Clarets again switching off at the back, Clark getting between two defenders to cleverly flick in a header from Ritchie's cross.
Burnley reduced the deficit before the break, Mee's long pass perfectly flighted for Wales striker Vokes to send a looping 18-yard header past Martin Dubravka.
Newcastle should have restored its two-goal cushion shortly after the restart but Ritchie somehow missed an open goal from three yards out when it was easier to score.
While not in Ritchie's league, Chris Wood wasted a good chance to earn Burnley an undeserved point when he shot straight at Dubravka, the New Zealand international later denied by Yedlin's outstanding block before he also fired a bouncing ball over the crossbar.
Joselu struck the post with 10 minutes to go after fine work from Ayoze Perez but Benitez's side held firm to collect another three points, leaving Burnley - for whom Vokes missed a last-gasp header - still in the mire.