The Rangers tied the game and won it against backup Coyotes goaltender Thomas Greiss after starter Mike Smith was injured late in the third period.
McDonagh was all alone in front of Greiss for a rebound off Dan Girardi's slap shot from above the right circle. Girardi had tied the game with 3:28 left in regulation when he deflected McDonagh's point shot.
The victory came after the Rangers celebrated Henrik Lundqvist setting the franchise wins record. It moved them one point ahead of Philadelphia for fifth place in the Eastern Conference.
Oliver Ekman-Larsson, Jeff Halpern and Kyle Chipchura scored for the Coyotes, who have lost two in a row for the first time since a four-game slide that spanned the Olympic break.
The Coyotes, clinging to the No. 8 seed in the Western Conference, lost Smith after Brassard fell on top of his legs in the crease. The team did not have any immediate information on the extent of his injury.
Smith had 25 saves and Greiss stopped seven of the nine shots he faced.
Richards scored 6:10 into the second period, getting his stick up to deflect a point shot by Carl Hagelin past Smith from in front of the crease.
Brassard tied the score at 2-2 less than five minutes later when he ended up with his own rebound on the low right side and beat Smith on a sharp-angle shot.
But the Coyotes regained the lead at 3-2 when Chipchura threw the puck toward the crease from near the left boards and Rangers winger Chris Kreider deflected it into his own net at 16:51 as he skated near the crease.
The Rangers honored Lundqvist in a pre-game ceremony six days after he set the franchise record for wins with his 302nd, passing Mike Richter.
Lundqvist, known for his guitar chops, received a powder blue Gibson Les Paul Custom from teammates and a mask emblazoned with the number 302.
Then, he gave up two goals in the first 8 minutes and 22 seconds.
Ekman-Larsson beat him with a wrister from the right circle on a power play 4:40 into the game and Halpern scored on a one-timer from the low slot to make it 2-0.