Eli Manning completed more passes Sunday night than any Giants quarterback in a single game. It was the record-setting 41st that everyone will remember.

Manning hit tight end Larry Donnell between two defenders in the back of the end zone with 21 seconds left to give the Giants a 30-27 win over the 49ers.

The old Giants record for completions in a game was 40 by Phil Simms, in 1985 against the Bengals.

It wasn't pretty, but neither is the NFC East. So maybe it's appropriate that the Giants used one of the ugliest wins of the young season to get past the 49ers and take sole possession of first place in the division for the first time since late in 2012.

"I'm happy for our guys," Tom Coughin said. "We finished the game the way we had to finish it. To come back and win, it's very exciting. I told them in the locker room it took every guy to secure it."

The Giants went into halftime ahead 13-6 but could have been up by much more. Their first drive was highlighted by a 49-yard catch and run by Odell Beckham Jr., who was wide open and would have scored had Manning hit him in stride. Later in that drive Andre Williams was unable to gain any yardage on third-and-1 from the 3 and the Giants settled for a field goal.

They found the end zone on their second possession when Manning hit Shane Vereen for a 2-yard touchdown pass. Their third drive had a chance to result in a TD, too, but Dwayne Harris dropped a third-down pass at the 10 and Josh Brown kicked a 41-yard field goal.

After the 49ers cut it to 13-6 with their second field goal of the half, the Giants had the ball with 1:01 remaining and again they seemed on the precipice of a touchdown, or at the very least some points. They executed a masterful hurry-up drive with Manning completing 5 of 6 passes until they had first-and-10 at the 14 with 11 seconds remaining. The Giants were out of timeouts but had enough time to try at least one and perhaps two passes in the end zone before settling for another field goal, but they didn't get that opportunity because Manning's pass for Beckham was intercepted by Tramaine Brock with 5 seconds left.

Those lost points became even more significant when the Giants had to punt for the first time in the game to open the second half and the 49ers, largely inept on offense with just 149 yards in the first half, marched 88 yards down the field to tie the score on a 3-yard touchdown pass from Kaepernick to Anquan Boldin.

The Giants were able to regroup offensively and retake the lead on Manning's 17-yard touchdown pass to Beckham with 1:14 left in the third. Beckham ran an in-route and caught the pass near midfield at the 15, then cut outside and beat cornerback Kenneth Acker in a sprint to the corner pylon. Manning completed all six passes on the seven-play drive.

But the 49ers were also finding their offensive footing and answered with an 80-yard drive aided by a pass interference penalty against Landon Collins that resulted in a 5-yard touchdown pass from Kapernick to Garrett Celek. Middle linebacker 'Uani Unga was in coverage on the scoring pass that tied it at 20 with 11:49 left in the fourth.

Notes & quotes: Defensive captain Jon Beason left early in the first quarter with a concussion, leaving the Giants without two of their three regular starters at linebacker as well as one of their top backups. Devon Kennard, the other starter, already had been ruled out and Jonathan Casillas warmed up but was inactive. Both are dealing with hamstring injuries . . . Stony Brook University's Will Tye caught three first-half passes for 44 yards, all of them for first downs . . . Osi Umenyiora, Chris Snee, Jack Lummus and John Johnson were inducted in to the Giants Ring of Honor at halftime.