Fernando Llorente at the double for Swansea
Liverpool had the better of the chances in the first-half at Anfield but neither side really looked like scoring in a goalless 45 minutes.
But just moments after the restart Swansea striker Fernando Llorente broke the deadlock for the visitors.
The Spaniard hit home from point-blank range after Swans defender Federico Fernandez headed down a Gylfi Sigurdsson corner.
Gylfi Sigurdsson goal earns valuable win for Swansea
And just four minutes later Llorente doubled Swansea's lead after he headed in a curling Tom Carroll cross from the left flank.
But Liverpool striker Roberto Firmino halved the deficit almost immediately with an equally stunning header from James Milner's cross on the right.
Jurgen Klopp's side looked set to be on for a dramatic comeback when Firmino bagged his second of the day with 22 minutes left to play.
The Brazilian chested down a Georginio Wijnaldum cross in the box and fired a low shot into the corner of Lukasz Fabianski's net.
Roberto Firmino double in vein as Liverpool lose
But hope of a comeback was short lived as Sigurdsson put Swansea ahead for a second time on 75 minutes to earn his side a valuable three points.
Liverpool missed the chance to cut the seven-point gap on leaders Chelsea and remain third in the Premier League.
Get Quotes on Home Insurance
While Paul Clement's side have lifted from the bottom of the table and out of the relegation zone by two points.