Match ends, Everton 0, Liverpool 1.
Sadio Mane's goal deep into injury time sank Everton and settled a scrappy Merseyside derby in Liverpool's favour at Goodison Park.
The Reds' £34m summer signing from Southampton reacted first to a loose ball after substitute Daniel Sturridge's shot had hit the post in the fourth of eight minutes of stoppage time.
Everton, who had lost goalkeeper Maarten Stekelenburg to injury in the second half, have now won just one of their past 20 meetings with their local rivals.
Liverpool - who moved up to second - created the better chances, with Stekelenburg and his replacement Joel Robles saving well from Roberto Firmino.
There was a flashpoint in the second half when a dreadful tackle by Ross Barkley on Jordan Henderson sparked angry scenes and the Everton midfielder was fortunate to escape with only a yellow card from referee Mike Dean.
- Barkley apologised for tackle - Henderson
- Relive Liverpool's dramatic Merseyside derby victory
- Football Daily podcast: 'Liverpool win proves title credentials'
Big win for Klopp and Liverpool
Liverpool manager Jurgen Klopp's celebrations at the final whistle carried an extra edge as Mane's late strike sealed three points they desperately needed to keep in touch with Premier League leaders Chelsea.
Liverpool are six points behind Antonio Conte's side and will surely take great satisfaction from digging out a vital victory that was based on grit rather than the flowing football that has been their trademark this season.
The hosts' high tempo start put the Reds on the back foot but as the game went on they exerted greater control and in the end deserved the win simply for looking the more dangerous side and creating the better chances.
And once again Sturridge proved how important he can be to Klopp and Liverpool's cause - despite being marginalised or injured for much of the season - with the run and shot that struck the post before Mane swooped to win the 227th Merseyside derby.
Liverpool needed to bounce back from the stumbles of a shock 4-3 defeat at Bournemouth and a home draw against West Ham United. They have done so in style with away wins at Middlesbrough and now Everton.
Everton's wait goes on
Everton's record in Merseyside derbies has been a tale of almost unbroken misery since their last win, a 2-0 win against Roy Hodgson's Liverpool in October 2010.
There are, however, signs of improvement and they will feel unfortunate not to hold out here and concede so late on.
For the first 45 minutes they adhered to boss Ronald Koeman's demand for a high-intensity pressing game but ran out of steam after the break, not helped by the loss of James McCarthy to injury.
Substitute Gareth Barry may still possess the old guile, but sadly for him and Everton the legs are also ageing and he was miles off the pace - though his substitute appearance did take him second behind Ryan Giggs in the list of most Premier League games played.
Everton also failed to give sufficient support to main marksman Romelu Lukaku and Koeman will surely be looking to address this problem in the January transfer window.
There are signs that the Toffees are now moving in the right direction, despite suffering their first home Premier League defeat of the season - but Koeman still has much to do.
Barkley lucky not to see red
Barkley has been the centre of much attention this season, whether as the victim of tough love from Koeman or with transfer speculation as he enters the last 18 months of his contract.
Here he was centre of attention for different reasons after a late touchline lunge on his England team-mate Henderson in the second half that was somehow only punished with a yellow card.
It led to angry exchanges between the players, and Henderson and Barkley also clashed later, the latter wisely not rising to the Liverpool captain's bait.
Barkley's night was summed up by a wild cross into the Gwladys Street that brought a furious response from his manager.
These are tough times for the talented 23-year-old midfielder.
Man of the match - Ragnar Klavan (Liverpool)
'You have to adapt to Everton's wild game' - what they said
Everton manager Ronald Koeman told BBC Sport: "We are really disappointed to concede in extra time. The eight minutes killed us.
"We have to wait to see about Maarten Stekelenburg's injury - we will know more tomorrow - and James McCarthy has a hamstring injury.
"I know exactly how fast Sadio Mane is, he reacted so well. We did not deserve to concede this goal.
"Maybe Ross Barkley was lucky, it was a hard tackle."
Liverpool manager Jurgen Klopp told BBC Sport: "I don't agree it was a poor first half. Maybe not the best football - you have to adapt to Everton's wild game. A game like this you have to interrupt their rhythm with passing.
"In the second half it was clear they couldn't do the same. We were better, we didn't give one chance away I think.
"The goal was not the hardest shot from Sturridge, but hard enough. It was a wonderful feeling.
"I don't like the flares too much. I'm a little bit scared about this. It was a long, long stoppage time. We gave them no chance."
On Barkley's tackle on Henderson: "I saw it one time. Everything is clear. I think the referee had a difficult game. Maybe Ross was really lucky and Henderson was really lucky."
Everton sucker punched, again - the best match stats
- Everton have only won one of their past 20 Premier League Merseyside derbies versus Liverpool, losing 10
- This is Liverpool's fourth Premier League win over Everton that has come via a goal in the 90th minute or later
- Liverpool have won double the number of Premier League matches by 90th-minute winners against Everton than they have against any other opponent
- The first shot on target came in the 50th minute - the second-longest wait in a Premier League match this season after Swansea v Sunderland (51st minute on 10 December)
- Everton did not manage a shot on target until the 75th minute
What's up next?
Everton travel to champions Leicester City on 26 December (15:00 GMT kick-off), before a trip to Hull on 30 December (20:00). Liverpool host Stoke at 17:15 on 27 December and then welcome Manchester City to Anfield on 31 December (17:30).
- 22StekelenburgSubstituted forRoblesat 64'minutes
- 23ColemanBooked at 69mins
- 25Funes Mori
- 16McCarthySubstituted forBarryat 45'minutes
- 17GueyeBooked at 85mins
- 19E ValenciaSubstituted forCalvert-Lewinat 73'minutes
- 8BarkleyBooked at 68mins
- 6LovrenBooked at 56mins
- 20LallanaSubstituted forCanat 82'minutes
- 19ManéSubstituted forLeivaat 90+8'minutes
- 27OrigiSubstituted forSturridgeat 82'minutes
- Mike Dean
- Shots on Target
Second Half ends, Everton 0, Liverpool 1.
Substitution, Liverpool. Lucas Leiva replaces Sadio Mané.
Corner, Liverpool. Conceded by Seamus Coleman.
Attempt blocked. Roberto Firmino (Liverpool) right footed shot from the centre of the box is blocked.
Delay over. They are ready to continue.
Delay in match (Liverpool).
Goal! Everton 0, Liverpool 1. Sadio Mané (Liverpool) left footed shot from very close range to the bottom left corner.
Daniel Sturridge (Liverpool) hits the right post with a left footed shot from outside the box. Assisted by Nathaniel Clyne.
Foul by Roberto Firmino (Liverpool).
Gareth Barry (Everton) wins a free kick on the right wing.
Foul by Roberto Firmino (Liverpool).
Aaron Lennon (Everton) wins a free kick in the defensive half.
Corner, Liverpool. Conceded by Dominic Calvert-Lewin.
Sadio Mané (Liverpool) wins a free kick in the defensive half.
Foul by Idrissa Gueye (Everton).
Attempt blocked. Roberto Firmino (Liverpool) left footed shot from the centre of the box is blocked. Assisted by Emre Can.
Idrissa Gueye (Everton) is shown the yellow card for a bad foul.
Sadio Mané (Liverpool) wins a free kick in the attacking half.
Foul by Idrissa Gueye (Everton).