Georginio Wijnaldum gave the hosts a ninth minute lead but Issa Diop equalised for the Hammers shortly after and substitute Pablo Fornals shot the visitors into the lead after the break.
But Liverpool kept their unbeaten run intact with goals from Mohamed Salah and Sadio Mane extending their lead at the top of the table to 22 points.
The win ensured Liverpool equaled Manchester City’s record of 18 straight league wins in the 2017/2018 season and they can extend that run with victory over relegation threatened Watford on Saturday.
'I never thought it would be broken or equaled,' Klopp said after the game.
'We did it and I cannot believe it happened to be honest. Whatever will happen this season is an effort of all of us.
'But you are right it is very special. We all know that these numbers are very special. but we are in the situation, and we want to react. We said at the start of our time here that we wanted to create history and write our own stories and the players have clearly taken that seriously.
'The numbers, of course, are unbelievable, we know that it is special. But we have to be ready to fight to the end as everybody is fighting for everything right now. Now we prepare for the next one at Watford on Saturday and we have to be 100 per cent for the next one.'
Liverpool now need just four more wins from their remaining 11 games to confirm their status as the champions of England for the first time in three decades.