SANTA CLARA, Calif. -- Rookie quarterback C.J. Beathard passed for 288 yards and two touchdowns Sunday, leading the San Francisco 49ers to a 31-21 victory over the New York Giants, their first win under first-year head coach Kyle Shanahan after a 0-9 start.
Beathard completed 19 of 25 passes with touchdowns of 83 yards to wide receiver Marquise Goodwin and 47 yards to tight end Garrett Celek in the second quarter. Beathard, who was intercepted once, ran for an 11-yard score in the fourth quarter.
Quarterback Eli Manning completed 28 of 37 passes for 273 yards and two touchdowns for the Giants (1-8). He started his 208th consecutive game, tying his brother, Peyton, for the second longest streak in NFL history by a quarterback, behind only Brett Favre's streak of 297.
New York wide receiver Sterling Shepard caught 11 passes for 142 yards. Giants tight end Evan Engram caught six passes for 31 yards and a 9-yard touchdown, his fifth score of the season, tying a team rookie record. He caught a touchdown pass for the fourth straight week.
Running back Carlos Hyde rushed for 98 yards on 17 carries for the 49ers.
The last time two NFL teams met with a combined one or fewer wins this late in the season was Nov. 4, 1984, when 1-8 Cleveland beat 0-9 Buffalo 13-10.
Beathard completed 13 of 16 passes for 198 yards and two touchdowns in the first half to help the 49ers (1-9) build a 17-13 lead.
After a scoreless third quarter, Beathard extended San Francisco's lead to 24-13 on an 11-yard touchdown run with 14:53 remaining.
Rookie running back Matt Breida increased the 49ers' lead to 31-13 on a 33-yard touchdown run with 9:19 remaining.
Manning threw a 14-yard touchdown pass to Roger Lewis Jr. with 1:02 left making it 31-21. The Giants failed to convert the 2-point conversion.
The 49ers took their first lead at home this season at 3-0 when Robbie Gould kicked a 44-yard field goal with 12:40 left in the first quarter. Aldrick Rosas answered with field goals of 47 and 42 yards, putting the Giants ahead 6-3 with 1:07 remaining in the opening quarter.
The Giants drove to San Francisco's 22 early in the second quarter, but on second-and-4, defensive end Ronald Blair III forced a Manning fumble, and strong safety Eric Reid recovered at the 15.
Three plays later, Beathard connected with Goodwin for an 83-yard touchdown, the 49ers' longest play of the season. The Giants blitzed, and Goodwin beat cornerback Janoris Jenkins' man-to-man coverage on a deep post route to put San Francisco ahead 10-6 with 7:59 left in the half.
The Giants moved ahead 13-10 on Manning's 9-yard touchdown pass to Engram with 2:08 remaining in the half.
Beathard answered with a 47-yard touchdown pass to Celek. He hit Celek in stride on a crossing route, and the tight end sliced through New York's defense to the end zone, putting the 49ers ahead 17-13 with 28 seconds left.
NOTES: Giants LDT Damon Harrison Sr. left the game late in the fourth quarter with an ankle injury and did not return. ... Giants starting LG Justin Pugh (back) was injured in the first half and backup G D.J. Fluker (knee) in the third quarter. Neither one returned. ... 49ers LT Joe Staley (fractured orbital bone) returned to the starting lineup after missing one game. ... 49ers starting TE George Kittle (ankle) and starting DE Solomon Thomas (knee) were inactive. TE Garrett Celek started for Kittle, and DE Ronald Blair III started for Thomas. ... Giants MLB Kelvin Sheppard, who started in place of injured MLB B.J. Goodson (ankle), left the game in the third quarter with a groin injury and did not return.