Michael Owen snatched victory for United with a goal almost six minutes into injury time in one of the most dramatic Manchester derbies.
The Red Devils had led neighbours City three times, but had been pegged back on each occasion.
Craig Bellamy's third equaliser had come only 20 seconds from the end of normal time, yet their was to be one more twist in this 153rd meeting of the Manchester clubs.
The magnificent Ryan Giggs found Owen racing into the left side of the Manchester City penalty area.
Owen, with City defender Micah Richards at his shoulder, took the ball in his stride before clinically steering his right-foot shot beyond goalkeeper Shay Given and into the far corner of the net from ten yards.
The story of this memorable game began to unfold in the second minute when United opened the scoring.
Patrice Evra cut in from the left touchline before finding Wayne Rooney, who neatly slipped between Nigel de Jong and Richards before steering his shot in at the near post from six yards.
But City were given a lifeline back into the game 14 minutes later.
Joleon Lescott's innocuous ball to the left side of the United box saw a fatal hesitancy between goalkeeper Ben Foster and defender John O'Shea.
Former United striker Carlos Tevez, whose summer move to Eastlands stoked animosity between the clubs, pounced.
Tevez wrested the ball from Foster and teed up Gareth Barry, who stroked his left-foot shot home from the edge of the box.
City were the better side for the rest of the half and Tevez almost came back to haunt United when his shot from 12 yards in the closing seconds hit the post with Foster beaten.
United shook off their complacency at the start of the second half and regained the lead four minutes after the break.
A Giggs cross to the far post from the left edge of the box saw Darren Fletcher rise above Barry to head in from six yards.
Back game City with another equaliser six minutes later. Tevez touched the ball to Bellamy on the left and the City striker cut inside to score with a tremendous right-foot shot into the top right corner of the net from the edge of the penalty area.
The goal stung United into an all out assault on the City goal.
Given produced three magnificent saves to keep out two headers from Dimitar Berbatov and a vicious volley from Giggs.
The constant pressure finally told and City cracked with ten minutes left when Fletcher powered in to head Giggs' free-kick from six yards out.
But City were not finished and the indefatigable Bellamy pounced on an error by Ferdinand on the left.
Bellamy outstripped Ferdinand for pace before taking the ball along the left byline and tucking his shot beyond Foster and into the net from close range.
But there was to be one final twist with Owen providing it to end City's 100 per cent record this season in a game which will live in the memory for many years to come.