Anthony Martial fired the Red Devils ahead in the first half with a shot that City's goalkeeper should probably have kept out at his near post.
United survived some heavy second-half pressure until Scott McTominay scored an injury-time second after Ederson's throw went straight to his feet.
Ole Gunnar Solskjaer's side, beaten at home by City in their past three league meetings and the EFL Cup semi-final first leg, claimed a top-flight double over their city rivals for the first time since 2009-10 to leave the champions' title defence hanging by a thread.
Pep Guardiola's first league loss at Old Trafford brought an end to City's five-game winning run in all competitions, as United boosted their hopes of qualifying for next season's Champions League.
— Premier League (@premierleague) March 8, 2020
City were 3-0 up after 38 minutes on their last visit to their neighbours in the EFL Cup, but this was a cagier affair, with the only early chance of note coming through Raheem Sterling's low shot, which was comfortably saved by David de Gea.
United grew in stature, with Ederson making two saves from good Daniel James and Martial chances, but the City keeper was at fault for the opener as he allowed Martial's volley through his grasp after a clever Bruno Fernandes free-kick.
City were upset that Ilkay Gundogan had been punished for the challenge that led to the goal, but the visitors were fortunate three minutes before the break when Fred was booked for diving after he was tripped by Nicolas Otamendi in the box.
City had only one shot in the first half, their lowest tally in a league game since October 2018 against Liverpool, but Sergio Aguero, who later went off with an apparent thigh problem, had the ball in the net three minutes after the restart only for VAR to uphold the initial offside call.
Ederson almost gifted Martial a second with poor control only to make a timely challenge on the goal line, but it was City who were threatening the most, with Phil Foden's shot tipped over by De Gea and Sterling failing to connect properly with a Riyad Mahrez cross.
United held firm in the closing stages before Ederson made the result safe, his attempted throw to Benjamin Mendy rolling straight to McTominay, who curled home a fine first-time finish from 30 yards.
— Manchester United (@ManUtd) March 8, 2020
What does it mean? Title race is almost run
While few would have given City much chance of defending their title even with a win here, the result means Liverpool need just six more points to clinch their first Premier League crown. Victory takes United back into fifth place, three points behind Chelsea in fourth, and takes their unbeaten run to 10 games in all competitions.
Martial finally up for the fight
Martial is the first United player to score home and away against City in the league since Cristiano Ronaldo in 2006-07, and only the second after Eric Cantona to score in three top-flight derby starts in a row. He took a clattering from Fernandinho at times, as well as the post in the second half, but led United's line impressively.
The bell tolls for City thanks to Ederson clangers
Having failed to keep out Martial's strike, Ederson's poor control almost gave the United striker a second and underlined a strange lack of composure from the Brazilian. His rotten outing in the Manchester rain was compounded when, with seconds left, he threw McTominay a chance he could scarcely believe.
Photo Getty Images Caption: Anthony Martial (R) after scoring against Manchester City