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."
Sorry, we were unable to load match stats, please try again.