Angelo Ogbonna headed in the winner in stoppage time of extra time to send West Ham into the next round of the FA Cup at the expense of Liverpool.
Liverpool's hopes of making it to two domestic Cup finals ended after West Ham pulled off a 2-1 victory right at the death, courtesy their Italy international defender.
Mikhail Antonio opened the scoring for the Hammers, volleying in off a cross from Enner Valencia on the stroke of halftime. However, just after the restart, Philippe Coutinho, who had hit the post previously, brought Liverpool back to level pegging by sending in an astute freekick that rolled under the wall.
The match swayed one way and then the other from there, but it looked like this FA Cup fourth round replay was headed for penalties, before Ogbonna struck, rising high to power home a header off a freekick from Dimtri Payet, who was impressive again.
Liverpool manager Jurgen Klopp, though, was not too happy at the awarding of that freekick from Roger East, or indeed the overall performance of the referee, who he felt made some "funny decisions."
"They got a freekick without a foul and we conceded a goal," Klopp, returning after undergoing surgery on his appendix, was quoted as saying by The Guardian. "I'm not long enough here to judge these things. If you are satisfied with the performance of the referee, write it. If not, say it.
"There were a lot of situations that, on a better day, I would say are funny decisions. I would have made a few different decisions, on both sides. The only reason we were here was to go to the next round, so we are disappointed.
"Liverpool in this moment is not the most sunny. 2-0 in the lead [against Sunderland at the weekend], manager in hospital, out of the FA Cup, but tomorrow when we get up the sun will shine. If we want, all together, we can take a lot of positive things out of this game."
While Klopp was disappointed and left with hoping for a better tomorrow, West Ham manager Slaven Bilic was understandably over the moon after knocking Liverpool out of the FA Cup and keeping West Ham in contention for a trophy.
"It was a brilliant game and I was really proud of the boys and everyone who is connected with the club," Bilic told the club's official website. "I think it was a game that will go in the history as one of the biggest nights of the club because it is the FA Cup, it is the last season at the stadium, it is Liverpool and a late night kickoff.
"The match went into extra-time and we have a last minute winner. I am proud of the boys and they left their hearts on the pitch."