United, with Michael Carrick on the bench as caretaker manager, were watched by their new interim manager Ralf Rangnick and after the match Carrick announced he was leaving the club.
Carrick, who said the decision was "100%" his own, was unbeaten in his three matches in charge of the team after taking over following the sacking of Ole Gunnar Solskjaer last month.
United's fans paid tribute to Solskjaer before the game with a banner in the Stretford End declaring "20-Legend" - a reference to the Norwegian's old shirt number.
But it was another legend, Ronaldo, who took centre stage during an end-to-end game.
Arsenal took the lead in bizarre fashion in the 13th minute when from a corner United keeper David De Gea went down clutching his foot after he was stood on by team mate Fred and Emile Smith Rowe drilled a shot into the unguarded goal from the edge of the box.
As referee Martin Atkinson had not blown his whistle before the ball went into the net and no foul had taken place, the goal stood.
United's protests were to no avail but they fought back on to level terms a minute before the interval through a Bruno Fernandes strike after a delightful back-heeled set-up from Fred.
Ronaldo put United in front in the 52nd when Diogo Dalot found Marcus Rashford on the right and the winger's low cross was clinically converted for the Portuguese forward's 800th goal.
The Gunners struck back quickly through Martin Odegaard who arrived on the edge of the box to guide home a fine low ball from Gabriel Martinelli.
But Ronaldo notched the winner from the penalty spot after Atkinson went to the pitchside monitor and ruled that Fred had been brought down by Odegaard.
United climbed to seventh in the table, two points and two places below Arsenal and a massive 12 points adrift of leaders Chelsea.
"Every win is important. It's been hard for us. Today we got a great win. We can be satisfied because we beat Arsenal," Fernandes said.
Carrick, a former United midfielder, announced his decision immediately after the final whistle, bringing a close to his 15 years at the club.
"It’s not been an easy decision to make but I feel it’s the right one. I was going to take time off after I finished playing and it never happened. It feels like the right time to step away and what a way to finish," Carrick said in a statement.
Arsenal manager Mikel Arteta saw positives in his team's performance but thought they defended poorly.
"If you concede three goals at Old Trafford it is difficult to get a result. I was disappointed with the goals that we conceded," he said.
"There were a lot of things that I liked In the game. I liked the behaviour of individuals. When you score two goals at Old Trafford you expect to get something from the game and that is a regret, but that is our fault. That is what happens against this quality of opponent."