Second-placed Reading moved four points ahead of West Ham in the race for the Premier League with a crucial victory at Upton Park.
West Ham took an early lead through Carlton Cole before two goals in two minutes from Kaspars Gorkss and Noel Hunt gave Reading a half-time lead.
Ian Harte made it 3-1 from the penalty spot before Ricardo Vaz Te's header pulled one back for the hosts.
But Mikele Leigertwood's shot late on sealed victory for Reading.
The Hammers have slipped out of the automatic promotion spots at the expense of the Berkshire club, following a miserable run of one win in their last seven matches.
It has prompted an angry response from their disgruntled fans, with boss Sam Allardyce being forced
to defend his team's style of play.
Cole broke the deadlock for the Hammers in the ninth minute with a left-footed finish after a headed knockdown from Kevin Nolan, who had hit a post just seconds earlier.
Gorkss headed home Harte's inswinging corner in the 44th minute before Hunt converted on the stroke of half-time to give the Royals the lead.
Harte added a penalty after 59 minutes to further stretch their advantage, but the Hammers responded with a Vaz Te header after 77 minutes.
But Leigertwood's strike six minutes from time eventually wrapped up the win for Reading.
Allardyce's men are now four points behind their rivals with only six games to play.
West Ham boss Sam Allardyce:
"We shot ourselves in the foot.
"We gifted them three goals. We can't afford to make those errors and that's ultimately why we got beaten.
"To keep up with Reading we have to win six on the trot."
Reading manager Brian McDermott:
"It's three points, that's all it is.
"It's never easy to go 1-0 down here but we stayed in the game, got ourselves a goal and to go in 2-1 up was massive.
"Then in the second half I felt we deserved to win. But I've been around this game a long time so I'm not cock-a-hoop yet."
West Ham United 01 Green 03 McCartney 05 Tomkins Booked 15 Faye 18 Faubert Booked 04 Nolan 14 Taylor (Baldock - 60' ) 16 Noble (Collins - 46' ) 32 O'Neil 09 Cole (Maynard - 72' ) 12 Vaz Te Substitutes 25 Collins 22 Lansbury 07 Baldock 08 Maynard 11 Carew Reading 01 Federici 05 Pearce 17 Gorkss 23 Harte 24 Cummings 04 Karacan (Tabb - 55' ) 08 Leigertwood 11 McAnuff 14 Kebe (Afobe - 82' ) 10 Hunt 33 Roberts Booked Substitutes 12 McCarthy 07 Tabb (Robson-Kanu - 67' ) 19 Robson-Kanu 18 Church 51 Afobe