Striker Greg Pearson hit an 80th minute winner for Tony Carr's team, who should really have won by more goals in a game they dominated.
After hitting the woodwork three times, the Hammers finally got the all-important breakthrough when James Allen skipped down the right and sent over a deep cross that was volleyed goalwards by Mitchell Cole. The Chelsea goalkeeper could only manage to tip the ball on to the crossbar and Pearson was on hand to stab home the rebound from six yards out.
It was just rewards for the visitors, who had earlier seen Pearson and Cole hit the post, Billy Mehmet hit the bar and Ronnie Fletcher have a header cleared off the line, while the Blues didn't register their first shot on goal until the 44th minute.
Said Tony Carr: "It was a thoroughly deserved victory after we had dominated for so long, but at 0-0 it was always edgy and we never felt comfortable until the goal had gone in.
"We had more than enough chances to have wrapped the game up earlier and I was beginning to think it wouldn't be our day, but the players showed tremendous character and it was a well-worked goal that won it for us in the end.
"That's now three away wins on the trot after losing at home to Ipswich, which is a very pleasing record. We are away again for the next two matches, at Crystal Palace and Fulham, so the aim is to carry that on and make it five in a row."
Team: Jackson, Khan, Tattam, Ferdinand, Fletcher, Lumsden, Allen (Akinsete 80), McMahon, Mehmet (Eastwood 80), Pearson, Cole (Morris 85). Subs unused: Ward, McClenahan.
Meanwhile, midfielder Ian Tucker grabbed the winning goal as Kevin Keen's under-17s beat Charlton Athletic at Little Heath.
After schoolboy goalkeeper Darren Behcet had made an excellent save to deny the Addicks early on, the Hammers hit what proved to be the only goal of the game in the 35th minute, when Tucker struck the bar with a shot and then followed up to head in the rebound from close range.
A solid second half performance allowed the hosts to hold on to their lead and Keen said: "It was a good defensive performance and the goal was well taken.
"Ironically, though, we played better against Coventry last week and lost, but that is football for you and it is pleasing to get a result even though we were not on top of our game.
"We now have another three London derbies in a row and it is nice to get back to winning ways before we face Spurs next week."
Team: Behcet, Wright, Laws, Parrington, Cohen, Blewitt, Tucker, Noble, Bunce, Collington, Stokes (Yao 70). Subs unused: Singh, Henry, Reed, O.Allen.