Wednesday took a shock lead early on in Sunday’s third-round tie through striker Atdhe Nuhiu, slotting home from just inside the area.
But five-time FA Cup winners City were level with 26 minutes remaining after Milner slipped the ball under Chris Kirkland from 10 yards.
Minutes away from an unwanted replay at Hillsborough for the Premier League side, Milner grabbed his second of the game from a yard out after Jesus Navas’ fine work on the right of the penalty area.
City dominated early on and had the first half chance, but Jesus Navas’ effort from just outside the area flew over the goal, minutes after the Spaniard’s dangerous cross had evaded the advancing Stevan Jovetic.
But the side 28 places below the Premier League champions were ahead after 14 minutes through Nuhiu, slamming past Willy Caballero in the City goal after Stevie May did well to find the giant striker 16 yards out.
The hosts had the chance to get back on level terms a few minutes later, but the unmarked Fernando could not direct his header towards goal from a corner.
Frank Lampard went close for City midway through the first half, dragging a shot from 18 yards just wide of Chris Kirkland’s goal after good work from Jovetic.
Wednesday looked to add to their lead after the break as the teams returned unchanged, having plenty of the ball in City’s half and forcing Cabellero into two comfortable stops.
Pellegrini brought Samir Nasri and David Silva on early in the first half, and it was the former who found Milner inside the area on 64 minutes for the Englishman to slide under Kirkland for the equaliser.
City piled on the pressure in the final 20 minutes despite the occasional counter attack from the visitors, and it was Milner with his and City’s second in stoppage time, directing Navas’ low cross into an empty net.