The visitors arrived at the Etihad Stadium on a run of four games without a win, but they condemned their neighbours to a fifth home league defeat of the season to close the gap on the top four to just one point.
© Getty Images
The hosts enjoyed some early joy down the left flank and created the first opening of the match via that avenue when Raheem Sterling's cross was only cleared as far as Jesus Navas, who chested the ball down but could only volley wide.
Yaya Toure then picked up a loose ball inside the United half before combining with David Silva and Sterling to create another chance for Navas, but this time the Spaniard's low strike was kept out by the feet of David de Gea.
That gave United a boost and they almost added a second in quick succession when Anthony Martial span into shooting space before seeing his powerful 25-yard effort beaten away by Hart.
Demichelis had failed to cut out either United attack, and he missed a chance to make amends at the other end shortly afterwards when he glanced a header wide when towering over Marcos Rojo in the area.
City began to create the better chances once again as the half wore on, with Toure coming close with a curling effort that bounced just past the post before failing to get a clean connection on an opening at the back post under heavy pressure from Michael Carrick.
United arguably should have had the last laugh at the end of the half, though, as Rashford went down under the challenge of Demichelis and was unfortunate not to see Michael Oliver point to the spot in the final minute of first-half stoppage time.
© Getty Images
The second half started no better for the beleaguered Demichelis as his back-pass in the very first minute sold Hart short and forced the keeper to come off his line and clear the ball. In doing so, the England number one pulled his calf and had to leave the field on a stretcher as a result, being replaced by Willy Caballero.
Demichelis was hauled off himself moments later as Manuel Pellegrini opted to move Fernandinho back into an unfamiliar centre-back role, and the Argentine's replacement Wilfried Bony almost made an immediate impact but couldn't connect properly with a header at the back post.
Caballero was called into action for the first time seconds later when he pushed Martial's deflected strike away from goal, while Rashford saw a close-range effort hit Fernandinho and go behind for a corner shortly afterwards.
City's pressure began to grow with their desperation for an equaliser, and they came within inches of getting one in the 66th minute when Aguero got across his man and planted a near-post header against the upright.
There was another headed chance for the Argentine with a little under 20 minutes left when Silva picked him out at the back post, but he could only steer his effort back across the face of goal, where neither Toure nor Bony could bundle it home.
Navas had another powerful effort that flew over the bar as City's shot count grew, although few of them tested De Gea as United continued to hold on.
The hosts were given six minutes of added time to find a leveller, and they perhaps should have done so in the first of those when Aguero took Silva's pinpoint pass down inside the area, only to drag his shot wide of the near post.
That proved to be the last opening for either side, however, as United clung on for a priceless victory to take them level with West Ham United and one point behind Pellegrini's side, who remain 15 adrift of leaders Leicester City.