Burnley endured another disappointing day-trip to the capital as the Hammers put a further dent in their unflattering away record in a bizarre game in East London.
After conceding eight goals in losing at Chelsea and Tottenham, the Clarets shipped another five to continue a wretched run at Upton Park which has seen them win only once in 20 visits.
But whereas Owen Coyle's men had failed to get on the scoresheet on their previous visits to London this season they did strike three times here to limit the damage in a remarkable finish.
Steven Fletcher took his tally for the season to eight as he twice profited from excellent work from the impressive Chris Eagles.
And Eagles then got a deserved goal in injury-time as Burnley finished with a flourish.
Had substitute David Nugent taken two decent chances after coming off the bench with the score at 4-0 the Hammers could have been made to sweat.
But again the Clarets' strikeforce was left with too much to do thanks to another uncertain defensive display, capped by Steven Caldwell's late dismissal, which triggered a sixth away defeat of the campaign.
Coyle had gone with an unchanged line-up for the fifth game in a row as the Clarets looked to build on a three-match unbeaten run and earn their first success on the road.
They made an impressive start with Andre Bikey letting fly with a shot which cannoned back off the chest of Robert Green and Clarke Carlisle seeing a header cleared off the line by Scott Parker from a Robbie Blake corner.
The Clarets looked capable of out-passing a Hammers' side struggling to find a winning formula under Gianfranco Zola.
But after an uncertain start the home side fired a warning blast when Guillermo Franco headed against the bar and then with 17 minutes gone they went in front.
Burnley were caught out by a quickly taken free-kick from Scott Parker which allowed Jack Collison to beat the off-side flag and get in behind Stephen Jordan to beat the exposed Brian Jensen.
It was a poor goal for the Clarets to concede but they at least responded positively as only a superb tackle from Manuel Da Costa stopped Fletcher in his tracks after Eagles had given the striker a sight of goal.
Then when Fletcher and Robbie Blake combined well, Wade Elliott had the chance to mark the 400th league appearance of his career with an equaliser but from the edge of the penalty area he lifted his shot over the bar.
But West Ham always remained a threat going forward with Franco a constant menace and after he had headed over he teed up Stanislas to make it 2-0 after 34 minutes.
Burnley's back four was again caught out by a clever pass to Stanislas who timed his run perfectly to be faced only by Jensen.
The goalkeeper blocked his first effort but when the ball came back to Stanlislas, the midfielder was allowed too much time to line up a second attempt which he put through Jensen's legs and in off the far post.
And it went from bad to worse three minutes before half-time when the Hammers added a third. This time Radoslav Kovac's pass caused the problems but Blake and Jordan should have dealt with it between them instead of allowing Jonathan Spector to pinch the ball and run into the box, where he was pushed over by Blake.
Carlton Cole had been limping moments earlier but the England international needed no second invitation to take the spot-kick, which he rolled beyond Jensen.
Coyle switched things around at the start of the second half as he stuck with the same personnel but in a 4-4-2 formation in an effort to get back into the game.
The changes weren't long in coming, though, as Burnley went 4-0 down after 51 minutes to prompt a double change from the bench as Nugent and Christian Kalvenes came on.
By then the Clarets were further adrift as they contested a free-kick for a foul on Zavon Hines by Jordan but then allowed Franco a free header to beat Jensen from six yards.
It was threatening to turn into a damaging defeat when Nugent missed two excellent opportunities in the space of as many minutes to reduce the arrears.
The substitute first mis-hit a shot wide following good work by Eagles and Fletcher and then headed past the post from Elliott's cross.
To rub salt into the wounds West Ham then scored their fifth when substitute Luis Jiminez was tripped by Jensen and picked himself up to slot home from the penalty spot.
With the home side seemingly in cruise control, a heaviest defeat of the season beckoned. But with 22 minutes to go the Clarets pulled one back through top-scorer Fletcher who tapped in his seventh goal of the season from a low cross from the persevering Eagles to launch a spirited fightback.
And the pair combined again seven minutes later as Burnley refused to go down without a fight, Eagles teeing up Fletcher at the far post for another close-range finish.
Eagles then fired a free-kick against the outside of a post and after Caldwell pulled back Hines to earn a red card in stoppage time the Clarets' winger got the goal his personal display merited when he converted a low cross from Mears which had been cleverly dummied by Fletcher to make it 5-3 and leave the Hammers glad to hear the final whistle.
Burnley: Jensen, Mears, Jordan (Kalvenes 55), Carlisle, Caldwell, Alexander (McDonald 70), Bikey, Eagles, Elliott, Fletcher, Blake (Nugent 55). Substitutes: Penny, Duff, Gudjonsson, Thompson.
West Ham:Green, Gabbidon, Parker, Franco (Jimene 60), Cole (Hines ht), Kovac, Spector, Da Costa, Ilunga, Collison (Faubert 77), Stanislas. Substitutes: Noble, Nouble, Tomkins, Kurucz.
Referee: Chris Foy.