Everton were hit by a late sucker punch at Goodson Park as Tomas Soucek pounced to score from close range and keep Carlo Ancelotti’s team pinned in fourth in the Premier League table.
A game which saw the return from injury of James Rodriguez as a second-half substitute, but was short on energy and opportunities, was drifting towards a stalemate until Soucek changed its course with four minutes remaining.
The Czech had an initial strike repelled by Jordan Pickford after striding onto Andriy Yarmolenko’s chipped pass.
Soucek hung around, though, staying onside, and was perfectly positioned to prod in when Aaron Creswell returned a shot from 20 yards.
Everton remained in the top four at full-time but were unable to become the first Premier League team this season to win five straight matches.
Manager Ancelotti's team had 10 goal attempts but only two on target and were unable to muster a grandstand finish following the visitors' strike.
West Ham were content to sit off Everton, waiting to suffocate the home team when they crossed the halfway line.
Trying to create space among this forest of claret-and-blue shirts – with Said Benrahma routinely backtracking to complete a five-man midfield – represented a test of patience and imagination.
Abdoulaye Doucoure popped up high on the right and Seamus Coleman added thrust from full-back as Everton attempted to make inroads.
Gylfi Sigurdsson, too, worked across the width of the pitch and his low cross following good approach play by Doucoure and Bernard was steered back to Darren Randolph by the outstretched leg of Craig Dawson.
West Ham have a few tricks up their sleeve going forwards, too.
Most notably, boasting an army of six footers, they are horrible to defend against at set-pieces.
Sebastien Haller, one of those towering figures, was wide with his header from Cresswell’s corner after 24 minutes – West Ham drawing level with Everton on two goal attempts despite their possession share of roughly one-third.
Meanwhile, Tom Davies slipped as he had a go from distance and sent his shot wide. Jarrod Bowen’s effort from a similar range slammed into Mason Holgate, restored to the middle of Everton’s defence after a run at right-back.
Pickford watched a Cresswell drive speed past his left post after the full-back was teed up by Benrahma.
Ancelotti instructed Bernard and Richarlison to swap wings midway through the opening half.
And from his position on the right, Bernard, starting for the first time since the game here against Manchester United eight weeks ago, began wielding an influence shortly before the break.
Doucoure, noticeably trying to inject more pace into Everton’s passing, swept the ball first-time for Bernard, who was tripped as he tried to skip past Pablo Fornals.
Sigurdsson’s free-kick carried right across goal and was gathered on the left by Bernard, this time earning a corner off Bowen.
The dead ball – again delivered by Sigurdsson – was partially cleared by Dawson after Yerry Mina’s initial header but only as far as the edge of the box.
Bernard again, controlling on his chest and returning a dipping volley which goalkeeper Randolph plunged to his right to tip behind.
Declan Rice threw his hands to his head when the midfielder’s cross from the left flew across the face of goal and eluded Haller at the back post 10 minutes after half-time.
Before that Richarlison – back on the left – slammed a penalty-box strike into the impressive Vladimir Coufal.
Cresswell’s left boot contains enduring potential to cause harm and the full-back had a free go at goal around the hour when Ben Godfrey hauled down the raiding Coufal.
Pickford, hitherto a relative spectator, watched Cresswell’s whipped strike from the right of the box all the way onto his palms to make a very good save.
Coleman raced forwards to collect a Bernard pass but couldn’t gain enough power to extend Randolph.
Fornals next, as the game began to open up, glancing a header wide after Bowen sent over an inswinging cross from the right.
Either side of that attempt, Pickford had his hands stung by a Fornals drive and dropped to his left to save a poked attempt from substitute Michail Antonio.
Bowen’s number went up soon after a tired challenge on Richarlison gave Everton a free-kick wide on the left, currency even more valuable with James on the field following his 64th-minte introduction, along with Andre Gomes.
The delivery was headed clear nonetheless and, with 12 minutes remaining, Ancelotti played his final hand, replacing Dominic Calvert-Lewin with Cenk Tosun.
It would be West Ham who claimed a decisive strike, however, Soucek scoring only the second goal Everton have conceded in five matches to snaffle the three points.