A power-play goal by Mark Giordano with 4:09 left in the opening period created a 2-2 tie and that is the way it stayed until McDonagh barely beat the overtime horn by putting a wrist shot past Henrik Karlsson.
The Rangers won their second in a row after losing their first three games of the season.
Brandon Prust put the Rangers back in front on a shorthanded tally with 6:18 left in the first.
Henrik Lundqvist stopped 32 shots for the Rangers. Karlsson made 25 saves.
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need
Couple mistakenly served bag of cash at McDonald's drive-thru