(CNN) -- Paul Scholes came out of retirement for a shock return as Manchester United beat FA Cup holders Manchester City 3-2 in Sunday's dramatic third-round tie between England's top two teams.
The 37-year-old former England international quit at the end of last season, but was named as a substitute by manager Alex Ferguson after agreeing to return for the rest of this season.
He came off the bench just before the hour mark to be cheered by the visiting United fans at the Etihad Stadium, with the Premier League champions already 3-0 ahead.
Scholes' return was not entirely successful as his mistake led to City's second goal, scored by Sergio Aguero, but United held on for a hard-fought victory.
Premier League leaders City had captain Vincent Kompany sent off after 12 minutes and were 3-0 down at halftime before forging a comeback.
The defender's red card could cost him a four-match ban, which would be a blow to City's hopes of a first league title since 1968 given that Yaya and Kolo Toure are away for a month at the African Cup of Nations.
City manager Roberto Mancini said the club would appeal Kompany's second straight red this season, which came for a two-footed lunge on United winger Nani in the 12th minute at 1-0 down.
"We will appeal. I am sure we will win," Mancini said.
Wayne Rooney scored twice for United, either side of Kompany's controversial red card, as he returned to form following reports that the club wanted to sell him.
He said Scholes' recall had been a big surprise.
"It was a bit of a shock to be honest, we didn't know until we were in the dressing room, but he's a great player," Rooney told ITV Sport.
Ferguson opted for Scholes, who has been working with the reserves at United, with his squad hit by an injury crisis.
"It's fantastic that Paul has made this decision," Ferguson said before the match started.
"He has kept himself in great shape and I always felt that he had another season in him. It's terrific to have him back."
Rooney's 10th-minute header put United ahead, then Kompany was dismissed by referee Chris Foy soon after.
Fellow striker Danny Welbeck made it 2-0 with a superb volley before earning the spot-kick to give Rooney the chance to score his second.
Rooney saw his effort saved by City's stand-in keeper Costel Pantilmon -- who replaced rested England No.1 Joe Hart -- but then headed home the rebound.
Aleksandar Kolarov gave Roberto Mancini's men an early second-half lifeline with a free-kick from the edge of the area before the entry of Scholes.
His mistake let James Milner cross for Aguero's goal, but otherwise he gave an assured display in his return to the big time.
United's reward for beating their local rivals is a mouthwatering fourth-round tie at Liverpool, who beat Oldham 5-1 Friday.
It will be the first clash between the two sides since the October league clash which led to an eight-game ban for Luis Suarez for racially abusing United's Patrice Evra.
Everton-Fulham is another confirmed all-Premier League tie, while Arsenal, if they beat Leeds on Monday, will be at home to Aston Villa.
In Sunday's other third-round action Sunday, Ramires scored twice as Chelsea enjoyed a 4-0 victory over Portsmouth at Stamford Bridge.
His late double and an added time fourth for Frank Lampard were hard on Pompey, who had restricted Chelsea to a goal by Juan Mata in the 48th minute.
Chelsea will face the winners of the MK Dons-QPR replay, while Sunderland who won 2-0 at Peterborough Sunday to continue their remarkable revival under Martin O'Neill, will play Middlesbrough in a north-east derby.