Liverpool twice let leads slip and lost Mohamed Salah to injury before Divock Origi came to the rescue at St James' Park.
Liverpool's Premier League title challenge remains alive after Divock Origi scored an 86th-minute winner in a dramatic 3-2 victory at Newcastle United on Saturday.
Origi got a decisive touch to fellow substitute Xherdan Shaqiri's free-kick to lift Jurgen Klopp's side off the canvas and back two points ahead of Manchester City, who visit Leicester City on Monday before the season comes to an end next Sunday.
The Reds' dreams appeared to have slipped away after Salomon Rondon fired in Newcastle's second equaliser in the 54th minute, which preceded a concerning head injury that forced Mohamed Salah off on a stretcher.
Virgil van Dijk and star man Salah had earlier scored either side of Christian Atsu's close-range strike, but it was Origi who provided the match-winning moment in a see-sawing contest.
Defender Van Dijk lit the fuse on a rollicking match by punishing Newcastle's shambolic marking in the 13th minute.
Trent Alexander-Arnold delivered the corner for his fellow defender's free header and was fortunate to avoid sanction as the hosts issued a swift response.
Rondon's close-range shot bounced back off the right-back's arm and was swept in by Atsu in the 20th minute, with referee Andre Marriner leaving the goal-line handball unpunished.
His decision came into sharper focus moments after Ayoze Perez fired against the crossbar.
Liverpool ventured forward, Alexander-Arnold crossed from the right and Salah guided home a deft right-footed finish.
Daniel Sturridge squandered a good opportunity after the interval and Rondon soon gave him a lesson in finishing, rifling into the bottom-right corner after Javi Manquillo won a header on the edge of the area.
And, 72 hours on from the crushing Champions League loss to Barcelona, Liverpool's chastening week seemed set to end with the sight of Salah in anguish after a heavy collision with the onrushing Martin Dubravka.
But there was a final twist to come as Origi's attempted header flicked in off Jamaal Lascelles and returned the pressure back to champions City.