Palace, who had Jordan Ayew sent off in the second period, took a 57th-minute lead on home soil courtesy of Jean-Philippe Mateta penalty, but Mohamed Salah's 200th Liverpool goal levelled the scores in the 76th minute, before Harvey Elliott won it in the final moments.
The victory has seen Jurgen Klopp's side move above Arsenal to the top of the division, while Palace remain down in 14th, now on 16 points from 16 league games this term.
Liverpool had a half-chance inside the first two minutes, with the ball breaking to left-back Kostas Tsimikas in a shooting position, but his effort was always swerving wide of the post.
The Reds continued to look threatening in the final third as the first period developed, but excellent defending from Palace meant that opportunities were few and far between.
Both Ryan Gravenberch and Dominik Szoboszlai had shots blocked from the edge of the Palace box in the 17th minute, with the home side standing firm under a lot of pressure.
The game's first attempt on target actually came from Jefferson Lerma, but a quite brilliant save from Liverpool goalkeeper Alisson Becker, who flew across his goal, kept the score at 0-0.
Palace were then awarded a penalty in the 29th minute when Virgil van Dijk brought Odsonne Edouard to the ground, but the decision was overturned following intention from VAR, with Will Hughes adjudged to have fouled Wataru Endo in the build-up.
Unsurprisingly, there were boos and whistles from the home supporters, but it was a positive first-half performance from Palace, with Liverpool struggling to get going at Selhurst Park.
The Eagles were denied a penalty in the first period, but they were given the decision in the 56th minute, with Jarell Quansah adjudged to have fouled Mateta, and the Palace forward stepped up to find the back of the net, with Roy Hodgson's side taking the lead just before the hour.
There was certainly controversy about the decision, though, as play was allowed to continue for almost two minutes before the intervention of VAR.
Liverpool had a chance to level shortly after conceding, but Darwin Nunez just failed to get a touch on a brilliant Trent Alexander-Arnold free kick, before Alisson kept out a strike from Jeffrey Schlupp down the other end.
Van Dijk also missed the target with a header in the period that followed, before Palace were reduced to 10 men, with Ayew given a second yellow card for a challenge on Elliott, handing Liverpool a huge boost in the 75th minute.
The Reds then levelled the scores in the 76th minute, with Salah's effort from inside the box finding a route into the back of the net via a deflection, making it 200 Liverpool goals for the Egyptian.
Liverpool then won it in the 91st minute, with Elliott's strike from outside the box finding the back of the net to break Palace hearts at Selhurst Park.
Klopp's side thought that they had a third late on through Diaz; the offside flag kept Palace in the contest, and Alisson had to make a late save to keep out a header from Joachim Andersen, with the visitors claiming a huge three points, which have moved them seven ahead of the reigning champions Manchester City.
Liverpool's next Premier League match is at home to Manchester United next Sunday, while Palace will be aiming to bounce back when they head to Man City next Saturday.