The result gave Liverpool their third successive league win and lifted them up to sixth, strengthening their chances of a Europa League place next season and also keeping alive their slimmer hopes of a top four finish which would earn them a Champions League spot.
It also dented third-placed Spurs's hopes of closing in on Manchester City in second place and meant they failed to increase their lead over Chelsea and Arsenal in the race for a Champions League place.
It was their first league defeat since they lost 2-1, also on Merseyside, to late Everton goals three months ago.
Uruguayan Luis Suarez opened the scoring with his 50th goal for Liverpool after 21 minutes with a superb strike inside goalkeeper Hugo Lloris's near post following crisp work in the build-up from Philippe Coutinho and Jose Enrique.
But Spurs equalised just before half-time when Belgian centre-back Jan Vertonghen headed in a cross from Gareth Bale.
Gareth Bale's run of scoring in his last five league games ended, but Vertonghen found the target again when he fired Spurs ahead after 53 minutes after the Liverpool defence failed to clear.
But Spurs contributed to their own downfall with bad mistakes from Kyle Walker, goalkeeper Hugo Lloris and Jermain Defoe leading to Liverpool's second and third goals.
Walker's bad backpass to Lloris, who failed to clear the ball, allowed Stewart Downing to equalise after 66 minutes.
Then another error from striker Jermain Defoe, back in defence, put Benoit Assou-Ekotto under pressure and he fouled Suarez for the 82nd-minute penalty from which Gerrard sent Lloris the wrong way.
Manchester United top of the table on 71 points from 28 points followed by Manchester City on 59 and Spurs on 54 having played one more match. Chelsea are fourth on 52 from 28, followed by Arsenal on 47 and Liverpool on 45.
Jamie Carragher, who is retiring at the end of the season, said he was delighted to mark his 500th league appearance for Liverpool with what could prove to be a very important victory.
"We have not come from behind to win much this season so it is a massive result for us," said the former England defender.
"But today we showed a lot of character and quality to beat a top team like Tottenham."
Tottenham manager Andre Villas-Boas admitted his side did shoot themselves in the foot.
"We made a couple of mistakes that cost us the game but we cannot be too negative after what we have done so far. The key moment of the game was when we could have gone 3-1 up through Gylfi Sigurdsson. It's football and we have to hopefully get ourselves back together and go on another good run."
In the day's other match, Newcastle United came from behind to beat Stoke City 2-1 at St James' Park where Papiss Cisse scored the winner in the last minute of stoppage time.
Stoke went ahead when Jon Walters scored from the spot after 67 minutes, but Newcastle won with a goal direct from a f
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.