Winston Reid's goal in the fourth minute of stoppage time secured a 1-0 victory for West Ham over luckless Sunderland at the London Stadium.
The bottom-placed visitors had looked poised to pick up their third point and first clean sheet of the season courtesy of a battling display, but were punished in the 94th minute as a quickly-taken Dimitri Payet corner found Reid on the edge of the box and the New Zealand defender fired a low shot into the bottom-right corner through a crowd of players.
The victory, just their second in the league at their new home, means that Slaven Bilic's men have now taken seven points from their last three games as they continue to climb away from the relegation zone.
Payet had come close to giving them the lead in the first half when he struck the post, but Sunderland could also have broken the deadlock early in the second half when Wahbi Khazri was denied by Adrian.
The visitors rallied well after enduring a torrid opening half-hour during which they could easily have found themselves two or three goals down and looked set for a valuable point as the game moved into stoppage time.
But David Moyes' men have struggled to defend against set-pieces all season and were made to pay the penalty once again as Reid struck to secure a third successive 1-0 win for West Ham in this fixture.
The first chance of the game fell the way of Payet after five minutes, with the France midfielder curling his shot narrowly wide following a neat one-two with Mark Noble.
And Payet again went close moments later, this time firing straight at Jordan Pickford having beaten three defenders during a surging run into the box.
With Noble pulling the strings in central midfield and Michail Antonio a constant threat down the right, the hosts continued to dominate for the opening half hour.
Simone Zaza and Edimilson Fernandes both saw goalbound efforts deflected wide before Payet went even closer on 26 minutes, thumping the base of the left post with a well-struck effort from the edge of the box.
Having weathered that early storm, Sunderland did eventually manage to force their way into the contest as Jack Rodwell headed a Khazri free-kick over the bar and Jermain Defoe then drew a regulation save from Adrian with a shot on the turn.
But it was West Ham who ended the first half as they had started it, with Zaza's spectacular overhead kick flashing past Pickford's right-hand post.
The second half began at a similarly lively tempo and Sunderland really should have taken the lead inside the opening minute.
The West Ham defence failed to cut out a through ball from Steven Pienaar, leaving Khazri clean through on goal, but the Tunisian midfielder's finish was weak, allowing Adrian to pull off a fairly comfortable save.
Defoe's long-range effort then flew over the bar as the game really opened up, with Fernandes also failing to keep a speculative 25-yard strike down at the other end.
It was the London side that spent the final quarter on the front foot, but Sunderland looked poised to keep them at bay until Reid's late effort flew past an unsighted Pickford into the bottom corner.