Manning had a career-best 41 completions and his perfect throw to Donnell finished off an 82-yard drive with a 12-yard touchdown. It made him the winningest quarterback in team history with 102.

Donnell was between Antoine Bethea and NaVorro Bowman, two of the 49ers' best defenders, when he leaped to snag the pass in the back of the end zone before falling on his back, the winning catch secured.

New York (3-2) has won three straight and leads the NFC East. San Francisco (1-4) has lost four in a row and let this one slip away after an impressive comeback.

Carlos Hyde's 2-yard run with 1:45 remaining gave the 49ers the lead. But on a night of huge plays and lengthy drives, Manning and Donnell had the topper.

There were 20 plays of at least 15 yards in the game, and San Francisco had three on its late drive. Then Manning, without his best weapon, Odell Beckham Jr., for much of the final series, engineered his 27th comeback victory in the fourth quarter or overtime.

Beckham's speed and moves were too much for the 49ers. He set up New York's first touchdown by using his elusiveness for a 31-yard reception down the middle. His 15-yard catch led to a 17-yard score on which he spun neatly and sped down the left sideline.

The touchdown was his last reception; he left with a hamstring injury, something that has plagued his short pro career, and returned only briefly on the winning series. Beckham finished with seven catches for 121 yards a week after he was fined for punching a Bills player in a win at Buffalo.