Liverpool preserved its unbeaten record in the Premier League by coming from behind to beat West Ham 3-2 thanks to second-half goals by Mohamed Salah and Sadio Mane in a thrilling game at Anfield on Monday.

The runaway league leaders tied the record for consecutive top-flight wins at 18 and successive top-flight home victories at 21 - but not without a scare against an opponent languishing in the relegation zone.

When Pablo Fornals gave West Ham a shock 2-1 lead in the 55th minute, Liverpool’s ambitions of becoming only the second team to go through a Premier League campaign unbeaten - after Arsenal in 2003-04 - was under serious threat.

Liverpool's Sadio Mane attempts to control the ball during the English Premier League soccer match between Liverpool and West Ham at Anfield Stadium in Liverpool, England, Monday, Feb. 24, 2020. (AP PhotoJon Super)

Liverpool's Sadio Mane attempts to control the ball during the English Premier League soccer match between Liverpool and West Ham at Anfield Stadium in Liverpool, England, Monday, Feb. 24, 2020. (AP PhotoJon Super)

But the Reds were stirred into action and after Salah’s 68th-minute shot squirmed through the arms and legs of West Ham goalkeeper Lukasz Fabianski and over the line in front of The Kop, Mane completed the comeback in the 81st.

A 26th win in 27 league matches restored Liverpool’s 22-point lead over Manchester City and left Jurgen Klopp’s team needing only four more victories to clinch a first English championship title in 30 years.

More AP soccer: https://apnews.com/Soccer and https://twitter.com/AP_Sports

Liverpool manager Jürgen Klopp, right, reacts during the English Premier League soccer match between Liverpool and West Ham at Anfield Stadium in Liverpool, England, Monday, Feb. 24, 2020. (AP PhotoJon Super)

Liverpool manager Jürgen Klopp, right, reacts during the English Premier League soccer match between Liverpool and West Ham at Anfield Stadium in Liverpool, England, Monday, Feb. 24, 2020. (AP PhotoJon Super)

Liverpool's Georginio Wijnaldum, left, celebrates with teammate Virgil van Dijk after scoring his team's first goal during the English Premier League soccer match between Liverpool and West Ham at Anfield Stadium in Liverpool, England, Monday, Feb. 24, 2020. (AP PhotoJon Super)

Liverpool's Georginio Wijnaldum, left, celebrates with teammate Virgil van Dijk after scoring his team's first goal during the English Premier League soccer match between Liverpool and West Ham at Anfield Stadium in Liverpool, England, Monday, Feb. 24, 2020. (AP PhotoJon Super)