Wayne Rooney scored and then missed a penalty on his return from injury as Manchester United reached the FA Cup fourth round at West Ham's expense.
The England striker, making his first appearance since Christmas, slid home from close in to put the hosts ahead.
West Ham were denied a penalty when the ball appeared to strike Rafael's arm in the penalty area.
But on a night of mixed fortunes, Rooney blasted a late penalty over to set up a tense finish at Old Trafford.
Rooney paying the penalty
- Wayne Rooney has now missed 10 penalties for Manchester United.
Matt Taylor went close for West Ham, but the home side stood firm to set up a home tie with Fulham on 26 or 27 January.
Having helped keep United in the tie at Upton Park with a delightful half-volleyed pass that set Robin van Persie on his way, Ryan Giggs once again stood out from the rest.
Sharper to the ball and swifter to use it, the Welshman delivered a midfield master-class, allying energy that belied his years to pace and purpose.
However, it was another night of frustration for Sam Allardyce's side. West Ham had been the better side in the first game only for Van Persie's sublime late goal to earn the Red Devils a reprieve. Once again, they had opportunities at Old Trafford but the chances and the tie slipped away.
Sir Alex Ferguson is not known for handing out second chances and for much of the first half his side dictated the tempo and toyed with their opponents. But even with Rooney and Anderson back after injury, Old Trafford felt subdued, perhaps expectant.
There was a sense that having come within minutes of a being knocked out of the FA Cup in the first leg, the Premier League leaders would not make the same mistake twice.
Ferguson's side made a dream start, snatching the lead through Rooney inside ten minutes.
The goal was as simple as it was effective. Anderson, making his first start since hobbling out of the 4-3 win over Reading on December 1, opened up the West Ham defence with a through ball that skidded into Javier Hernandez's path. The Mexican beat the offside trap, squared the ball to Rooney who slid the ball into an empty net.
Rooney pointed to the sky as he ran away to celebrate in memory of his late sister-in-law.
The Red Devils might have had a second after 28 minutes, as Giggs combined with Antonio Valencia to tee Nani up for a fizzing volley that was cleared off the line by the young West Ham defender Dan Potts.
It was too easy for Ferguson's side - the pace dropped, along with the temperature, and passes went astray. The visitors grew in confidence and in two spells either side of half time, West Ham seized the initiative.
Taylor twice went close in the space of two minutes, misplacing his pass when well-placed before firing over from 12 yards.
Sensing an opportunity, Allardyce threw Kevin Nolan and Jack Collison into the mix. The former Bolton and Newcastle midfielder almost made an immediate impact, only to see his shot blocked by Chris Smalling.
As West Ham pushed for an equaliser, United broke once more.
Another surging run by Giggs ended with his clipped cross striking the outstretched arm of Jordan Spence, prompting referee Phil Dowd to award a penalty.
Rooney, however, could only blast his spot-kick high over Jussi Jaaskelainen's crossbar.
Manchester United boss Sir Alex Ferguson on his team's record of five penalties scored and four missed this season: "I think we have to improve at that.
"There have been several great examples over the years -[(former Southampton midfielder] Matthew Le Tissier scoring 47 out of 48.
"A penalty kick is your opportunity to take advantage of a foul or a handball or whatever and score a goal."
- 13 Lindegaard
- 02 Rafael
- 04 Jones
- 12 Smalling
- 28 Buttner
- 07 Valencia
- 08 Anderson (Carrick - 67' )
- 11 Giggs
- 17 Nani (Scholes - 77' Booked )
- 10 Rooney
- 14 Hernandez
- 40 Amos
- 05 Ferdinand
- 16 Carrick
- 22 Scholes
- 26 Kagawa
- 19 Welbeck
- 20 Van Persie
West Ham United
- 22 Jaaskelainen
- 02 Reid
- 05 Tomkins
- 27 Spence Booked
- 33 Potts
- 14 Taylor
- 21 Diame (Collison - 65' )
- 23 Diarra
- 32 O'Neil
- 09 C Cole (Nolan - 65' Booked )
- 12 Vaz Te (Lee - 78' )
- 30 Spiegel
- 20 Demel
- 04 Nolan
- 07 Jarvis
- 10 Collison
- 43 Lletget
- 47 Lee
Live Text Commentary
Full Time The referee blows his whistle to end the game.89:48
Gary O'Neil gives away a free kick for an unfair challenge on Ryan Giggs. Free kick taken by Alexander Buttner.88:53
Jussi Jaaskelainen takes the direct free kick.88:53 Booking
Booking Paul Scholes booked.88:36
Matthew Taylor fouled by Paul Scholes, the ref awards a free kick.88:22
Alexander Buttner crosses the ball, clearance by Winston Reid.86:43
Alexander Buttner challenges Matthew Taylor unfairly and gives away a free kick. Matthew Taylor crosses the ball in from the free kick, clearance by Michael Carrick.85:56
Javier Hernandez is caught offside. James Tomkins takes the free kick.81:43
Centre by Jack Collison, blocked by Rafael Da Silva.79:29
Shot from just outside the box by Michael Carrick misses to the right of the target.77:59 Penalty
Penalty missed by Wayne Rooney.77:59
Handball decision goes against Jordan Spence.76:34
Michael Carrick takes the free kick.76:34 Substitution
Substitution Elliot Lee on for Ricardo Vaz Te.76:34 Substitution
Substitution Luis Nani goes off and Paul Scholes comes on.76:34 Booking
Booking Jordan Spence is cautioned.76:14
Jordan Spence concedes a free kick for a foul on Alexander Buttner.74:48
Matthew Taylor has a shot on goal from outside the box which misses left.74:15 Booking
Booking Kevin Nolan is cautioned by the ref for dissent.72:59
Wayne Rooney takes a inswinging corner from the left by-line to the near post, clearance made by Gary O'Neil.
The ball is sent over by Antonio Valencia.68:52
Free kick awarded for an unfair challenge on Alexander Buttner by Gary O'Neil. Direct free kick taken by Luis Nani.66:46
Unfair challenge on Luis Nani by Gary O'Neil results in a free kick. Free kick taken by Ryan Giggs.66:03 Substitution
Substitution Michael Carrick joins the action as a substitute, replacing Oliveira Anderson.65:46
Javier Hernandez takes a shot. Save by Jussi Jaaskelainen.63:49 Substitution
Substitution Mohamed Diame leaves the field to be replaced by Jack Collison.63:49 Substitution
Substitution (West Ham) makes a substitution, with Kevin Nolan coming on for Carlton Cole.63:49
Matthew Taylor takes a shot from just inside the penalty box which clears the crossbar.63:22
Luis Nani delivers the ball, save made by Jussi Jaaskelainen.62:44
Luis Nani decides to take a short corner.62:20
Oliveira Anderson has an effort at goal from outside the area which goes wide left of the target.59:55
The ball is delivered by Antonio Valencia, save by Jussi Jaaskelainen.59:14
Inswinging corner taken left-footed by Ryan Giggs from the right by-line.58:47
Free kick awarded for a foul by Mohamed Diame on Alexander Buttner. Wayne Rooney restarts play with the free kick. The ball is sent over by Ryan Giggs, Daniel Potts manages to make a clearance.58:29
The ball is delivered by Antonio Valencia, James Tomkins makes a clearance.56:01
Corner taken by Matthew Taylor. Gary O'Neil takes a inswinging corner.55:18
The assistant referee signals for offside against Winston Reid. Anders Lindegaard takes the free kick.54:28
Antonio Valencia gives away a free kick for an unfair challenge on Daniel Potts. Gary O'Neil takes the free kick.54:08
The ball is sent over by Jordan Spence, Phil Jones manages to make a clearance.52:52
Rafael Da Silva crosses the ball, comfortable save by Jussi Jaaskelainen.51:57
Gary O'Neil takes a shot. Alexander Buttner manages to make a clearance.51:16
Matthew Taylor takes a shot. Blocked by Oliveira Anderson.50:06
Corner taken by Matthew Taylor from the right by-line, clearance made by Chris Smalling.47:42
Javier Hernandez produces a right-footed shot from inside the area that clears the crossbar.45:54
The assistant referee flags for offside against Wayne Rooney. Free kick taken by Jussi Jaaskelainen.45:01
The referee starts the second half.45:00 +1:13 Half time
Half Time The first half comes to an end.42:57
Gary O'Neil fouled by Oliveira Anderson, the ref awards a free kick. Free kick taken by Winston Reid.42:22
Centre by Mohamed Diame.41:25
Wayne Rooney takes a shot. Save made by Jussi Jaaskelainen.40:22
Corner taken by Wayne Rooney played to the near post, clearance by Winston Reid.39:05
Unfair challenge on Matthew Taylor by Ryan Giggs results in a free kick. Winston Reid takes the direct free kick.38:29
Shot by Luis Nani from outside the box goes high over the crossbar.37:27
The ball is delivered by Jordan Spence, clearance made by Chris Smalling.33:37
The referee blows for offside. Indirect free kick taken by Jussi Jaaskelainen.31:49
Centre by Alexander Buttner.30:34
The referee blows for offside. Jussi Jaaskelainen restarts play with the free kick.30:13
Centre by Wayne Rooney, Jussi Jaaskelainen makes a save.29:41
Short corner taken by Wayne Rooney from the left by-line.28:48
Ricardo Vaz Te takes a shot. Comfortable save by Anders Lindegaard.27:58
Chris Smalling takes a shot. Save by Jussi Jaaskelainen.27:34
Luis Nani takes a shot. Clearance by Daniel Potts.27:07
Short corner taken by Ryan Giggs from the right by-line.22:29
Matthew Taylor produces a cross.21:40
The assistant referee signals for offside against Javier Hernandez. Jussi Jaaskelainen takes the free kick.20:07
Unfair challenge on Gary O'Neil by Antonio Valencia results in a free kick. Gary O'Neil crosses the ball in from the free kick, Carlton Cole gives away a free kick for an unfair challenge on Chris Smalling. Free kick taken by Anders Lindegaard.17:59
Mohamed Diame takes a shot. Blocked by Chris Smalling. Corner taken by Gary O'Neil from the left by-line to the near post, clearance by Javier Hernandez.14:54
Antonio Valencia produces a cross.13:11
Luis Nani takes a shot. Comfortable save by Jussi Jaaskelainen.12:05
The referee penalises Daniel Potts for handball. Free kick taken by Antonio Valencia.10:28
Luis Nani delivers the ball, clearance by James Tomkins.8:07
Assist on the goal came from Javier Hernandez.8:07 Goal scored
Goal! - Wayne Rooney - Man Utd 1 - 0 West Ham A goal is scored by Wayne Rooney from close range to the bottom left corner of the goal. Man Utd 1-0 West Ham.7:21
Ricardo Vaz Te takes a shot. Anders Lindegaard makes a comfortable save.5:32
Effort on goal by Alexander Buttner from long range goes harmlessly over the bar.4:42
Free kick awarded for a foul by Ricardo Vaz Te on Phil Jones. Anders Lindegaard takes the direct free kick.2:59
Corner taken right-footed by Wayne Rooney to the near post, Jordan Spence manages to make a clearance.2:12
Free kick awarded for an unfair challenge on Ricardo Vaz Te by Phil Jones. Free kick crossed by Gary O'Neil, Ryan Giggs makes a clearance.0:25
Ryan Giggs takes a short corner.0:00
The ref blows the whistle to start the match.
Live data and text provided by our data suppliers