West Ham striker Diafra Sakho scored a late winner to inflict defeat on new Sunderland head coach Dick Advocaat in his first match in charge and finally bring some cheer back to Upton Park.
The Irons were in contention for the European places earlier in the season but have slipped down the Barclays Premier League with a terrible run of form in 2015.
It looked set to be another frustrating afternoon for manager Sam Allardyce, who is out of contract in the summer, before Sakho slotted home with just two minutes left to give West Ham a first league win since January 18, 1-0, and leave Dutchman Advocaat in no doubt of the hard work ahead to secure Sunderland's top-flight status.
With former Hammer Jermain Defoe, Steven Fletcher and Connor Wickham leading the line, while Jordi Gomez was recalled, Sunderland - who named Adam Johnson on the bench - began in positive mood.
On eight minutes, West Ham keeper Adrian had to be alert to beat away an angled drive from Wickham after the visitors had again broken quickly.
West Ham, who had suffered three successive league defeats and were seven without victory, had to be patient in their response, which was delayed by a stoppage after Sunderland defender Wes Brown needed treatment for a knee problem.
Brown, who had fallen awkwardly in the Sunderland penalty area, was replaced by Santiago Vergini on 12 minutes.
Sunderland should have gone ahead on 14 minutes when Fletcher's flick-on put Defoe clear into the West Ham box.
However, the one-time England regular, who left the Irons for Tottenham in February 2004, crashed a right-foot half-volley high into the stands - much to the delight of those who once chanted his name around the Boleyn Ground.
After the scare, West Ham forced some pressure as Sakho headed a left-wing cross from full-back Aaron Cresswell just wide of the far post.
Advocaat had warned his team they needed to improve their work-rate and as the half-hour approached, the visitors continued to chase down when not in possession as their new Dutch taskmaster watched on from the edge of the technical area.
Sunderland goalkeeper Costel Pantilimon had to be alert on 31 minutes when Alex Song crashed a 25-yard volley goalwards, which was pushed away at full stretch down to his right by the 6ft 8ins Romanian.
As the teams laboured towards half-time, West Ham defender Cheikhou Kouyate glanced a header across the six-yard box and wide from a corner.
Allardyce made a change for the second half as winger Matt Jarvis was replaced by striker Carlton Cole, now fit again following a hamstring injury.
Sunderland, though, remained on the front foot with Defoe the main outlet.
West Ham were close on 51 minutes when Sakho dropped a header just wide following a deep cross by Cresswell.
The match then became somewhat scrappy as both sides contested the decisions of referee Lee Mason, with Wickham shown a yellow card on 62 minutes after a late foul on Mark Noble.
On 73 minutes, Johnson came off the bench, replacing Fletcher.
England international Johnson, 27, has been bailed until April 28 following his arrest on suspicion of sexual activity with a girl under 16 and returned to training this week following a club suspension.
The winger was promptly given a rousing reception by the travelling Sunderland supporters - along with a chorus of boos and expletives from the home fans.
Sunderland defender Patrick Van Aanholt let fly from 25 yards with a rocket towards the top corner, and Adrian had to be alert to tip the ball behind as Advocaat held his head in his hands on the touchline.
It proved a pivotal save, as West Ham grabbed a winner with just two minutes left.
As Sunderland appealed for a foul on the edge of the penalty area, Noble hooked the ball through to Sakho, who dispatched a cool, low finish into the bottom left corner.