Liverpool returned to the top of the Premier League but were made to work hard for victory at relegation-threatened Cardiff City.
Jurgen Klopp’s side had to be patient as they dominated a dogged Cardiff side, who had chances of their own to cause an upset.
Liverpool made the breakthrough in spectacular fashion, as Georginio Wijnaldum met Trent Alexander-Arnold’s low corner with a thunderous first-time effort which threatened to break the net.
The wild celebrations spoke of the visitors’ relief, and they had to negotiate some nervy moments, most notably a staggering miss by Cardiff captain Sean Morrison, who miscued a header with the goal at his mercy.
Things then got worse for Morrison, who conceded a penalty after grappling with Mohamed Salah, and substitute James Milner confidently converted the spot-kick to seal victory for the visitors.
Cardiff remain in the relegation zone, three points adrift of safety.
Liverpool, meanwhile, restore their two-point lead at the top of the table over Manchester City, who play their game in hand away at Manchester United on Wednesday.
The last time Liverpool were in Wales’ capital city in 2014, Luis Suarez scored a hat-trick in a 6-3 thrashing of a Cardiff side managed by Ole Gunnar Solskjaer and destined for relegation.
That chaotic encounter was symptomatic of Liverpool’s title challenge that season: thrilling and brimming with goals but also lacking the defensive fortitude of champions.
The Reds ultimately fell short – but this time it has been a different story.
There are still twists and turns to come in this absorbing title race but Liverpool now have the tightest defence in the Premier League.
A record of conceding only 20 goals in 35 games has allowed them to go toe-to-toe with a Manchester City side widely regarded as one of the greatest to have graced this competition.
Liverpool are a solid, patient, winning machine these days – their past five league victories had come thanks to second-half goals, and they had to bide their time here as well.
Klopp’s side imposed themselves immediately, monopolising possession and pinning their opponents back in their own half.
Their fabled front three all had chances to score in the first half: Roberto Firmino firing over when clean through on goal, Sadio Mane flicking a first-time effort over and Salah seeing a low shot smothered by Neil Etheridge.
Cardiff, however, were standing firm, with centre-backs Morrison and Bruno Ecuele Manga marshalling a robust defensive display from the hosts.
Liverpool did not panic and eventually engineered a way through their opponents with what seemed to be a pre-planned move, with Alexander-Arnold’s low corner steered towards the onrushing Wijnaldum, who swept in an emphatic finish.
Klopp’s side had chances to extend their lead – with Jordan Henderson spooning one particularly good one over – but this was another clinical display, Milner’s penalty making it nine successive wins in all competitions for the Reds.
In a season when the battle for Premier League survival has largely seemed a foregone conclusion – with Huddersfield relegated in March and Fulham in early April – Cardiff have been determined to buck the trend.
Written off by many at the start of the campaign, the Bluebirds appeared to be all but down before producing a display of great will and resolve to beat relegation rivals Brighton on Tuesday and revive their hopes of staying up.
Neil Warnock and his players like nothing more than to prove people wrong and, although they were rank outsiders on this occasion, Cardiff were in no mood to simply sit back and admire as their opponents continued to seek a first league title in 29 years.
The home side had to defend deep and in numbers as Liverpool bossed possession and territory; Warnock’s charges tenaciously stuck to their task in the face of constant pressure.
Cardiff were not without an attacking threat themselves, with winger Nathaniel Mendez-Laing demonstrating his speed and trickery to beat Alexander-Arnold three times inside the opening half-an-hour.
The Bluebirds were close to taking the lead shortly before the break, with Oumar Niasse – on loan from Everton – athletically hooking towards goal with a volley that was well saved by Alisson.
That gave the home crowd some hope and, even after Liverpool went ahead, Cardiff had their moments.
Only Morrison will know how he managed to miss with a near-open goal at the back post, the centre-back mistiming his dive and seemingly hitting the ball with his back.
His next major involvement was to prove the end of Cardiff’s hopes of snatching a point from this game, as he grappled with Salah and conceded the penalty that Milner converted to leave Cardiff three points behind 17th-placed Brighton, with three games to play – one fewer than the Seagulls.