West Ham scored two late penalties at Burnley to reach the quarter-finals of the Capital One Cup.
The visitors rarely threatened during the game, with Championship leaders Burnley having the better chances.
But the Premier League side went ahead on 76 minutes when Jason Shackell fouled Kevin Nolan and Matt Taylor made no mistake from the spot.
Keith Treacy was sent off after fouling Jack Collison in the box in injury time and the midfielder side-footed home.
In-form Burnley would have fancied their chances of causing an upset going into the game having won 12 of their 15 matches this season - a run helped by the impressive form of strikers Sam Vokes and Danny Ings, who have scored 21 goals between them.
Hammers turn the corner?
- The win was the Hammers's first in their last five away League Cup fixtures. It also marked the first time they have kept a clean sheet on their travels in the competition in 13 games
In contrast, the Hammers have managed just eight goals in nine Premier League games and some of the scoring responsibility at Turf Moor was handed to Carlton Cole, who was making his first start since
rejoining West Ham earlier this month.
Cole looked rusty in the opening stages and instead it was the Clarets who carved out the better of the early chances.
Junior Stanislas's low shot was pushed behind by West Ham keeper Adrian, before the Spaniard produced a fine one-handed save soon after to keep out Ings's rising effort from inside the area.
The Hammers seemed devoid of ideas going forward and their rare forays into the opposition half often ended with the final ball going to a Burnley player.
They did not manage an effort on target until 10 minutes before half-time, when James Tomkins sent a tame header into the hands of home keeper Tom Heaton.
West Ham improved after the break, though, as Modibo Maiga's close-range shot was cleared by a defender and then Joe Cole had the ball in the net with an acrobatic overhead kick, but he was flagged offside.
But they were fortunate not to be behind when Tomkins fouled Ings 25 yards from goal and Kieran Trippier's resulting free-kick smacked against the top of the crossbar.
Allardyce responded by taking off Tomkins and bringing on Nolan before switching to a 4-3-3 formation.
The change improved the Hammers's attacking play almost instantly and Ben Mee had to be alert to head away Maiga's cross with Stewart Downing lurking.
But with less than 15 minutes remaining, West Ham were gifted the lead when Maiga flicked the ball into the area for Nolan and the midfielder was brought down by Shackell, giving Taylor the chance to score from the spot.
Burnley tried to regroup and went close to snatching a quick leveller when Vokes managed to get his head to Michael Kightly's cross, but Adrian caught confidently.
West Ham ensured there would be no way back for the hosts when they scored a second in stoppage time.
A poor Heaton clearance was picked up by Collison, who raced into the box and was hauled down by Treacy, who was subsequently red carded.
Collison picked himself up to side-foot the penalty beyond Heaton and cement West Ham's place in the last eight.
Burnley manager Sean Dyche:
"[On the first penalty] I asked the referee and he said he was happy with his view; I wasn't as happy with his view.
"I think it's a very difficult position to see a penalty from. He's behind the play and three or four players, but I always respect referees' decisions and that's the way it is."
West Ham manager Sam Allardyce:
"The introduction of first Jack Collison at half-time then Stewart Downing, then Kevin Nolan as the game went on meant our quality of player got better and our quality of passing got better and better.
"In the end we were very, very happy that we won and I'm very happy with the team and the effort the players put in."
- 01 Heaton
- 02 Trippier
- 06 Mee
- 15 Edgar (Noble - 92' )
- 28 Long
- 05 Shackell Booked
- 26 Treacy Dismissed
- 22 Stock
- 09 Vokes
- 10 Ings
- 11 Stanislas (Kightly - 84' )
- 03 Lafferty
- 04 Duff
- 19 Kightly
- 32 Howieson
- 33 Hewitt
- 35 Noble
- 40 Liversedge
West Ham United
- 13 Adrián
- 37 Chambers
- 17 O'Brien
- 05 Tomkins (Nolan - 71' )
- 27 Potts
- 33 Ruddock
- 26 Cole
- 14 Taylor
- 24 Cole (Downing - 60' )
- 11 Maiga
- 21 Diamé (Collison - 45' )
- 04 Nolan
- 10 Collison
- 15 Morrison
- 23 Downing
- 29 Spiegel
- 38 Tombides
- 40 Fanimo
Ref: Robert Madley