SANTA CLARA, Calif. (AP) As the clock ticked down, coach Kyle Shanahan got doused with some Gatorade on a celebratory sideline for the San Francisco 49ers.

This win had been a long time coming.

C.J. Beathard threw for 288 yards and two touchdowns and ran for a third score to lead the 49ers to their first win of the season with a 31-21 victory over the New York Giants on Sunday.

''You lose 9 in a row, you learn to savor the moment and enjoy these,'' Shanahan said. ''It was tough work to get our first win and we got it. The guys knew how much it meant to me and I knew how much it meant to them.''

Beathard connected on an 83-yard TD to Marquise Goodwin and a 47-yarder to Garrett Celek in the second quarter as the 49ers (1-9) took advantage of another listless effort by the Giants (1-8) to win for the first time under coach Kyle Shanahan.

Beathard's time as starting quarterback in San Francisco figures to be numbered after the team acquired Jimmy Garoppolo two weeks ago in trade from New England. Garoppolo has been learning the offense and could take over when the team returns from the bye in two weeks.

But for now, the Niners are happy to be able to celebrate a win as they rest up for the stretch run.

''I've been a part of a lot of wins with this franchise over the 11 years I've been here,'' left tackle Joe Staley said. ''This win felt just as good as winning the NFC championship. It was unbelievable.''

While the Niners could be making a quarterback change soon, this performance will only heighten the questions about whether the Giants will need to change coaches. Ben McAdoo has been under fire after a report this past week from ESPN that quoted an anonymous player as saying the players have given up on the season and don't view McAdoo as a leader.

The Giants have not fired a coach during the season since 1976 when Bill Arnsparger was let go after a 0-7 start and replaced by John McVay, who had more success as an executive who helped build the 49ers dynasty in the 1980s.

''That doesn't have anything to do with anything,'' McAdoo said of his job security. ''We have to find a way to win a game. We have to address what happened out here on the field today, take a look at the tape and be honest with each other.''

This was a historically bad matchup, marking the first time in 33 years that two teams with only one combined win met this late in a season. Then the teams committed three penalties before the second offensive play of the game.

The Niners were the only team to pick up their play from there, using the two big TD passes from Beathard to take a halftime lead and then dominating the second half.

PLAYING WITH A LEAD

The Niners took a lead for the first time since Oct. 1 at Arizona when they got a field goal from Robbie Gould on the opening drive. The five games without holding a lead tied a franchise worst set in 1963. San Francisco also got its first first down while holding a lead of the season on a 40-yard pass from Beathard to Louis Murphy in the third quarter. That drive ended when Olivier Vernon had his first career INT when dropping into coverage on a screen.

GO-TO GUY

Giants rookie TE Evan Engram caught a TD pass for the fourth straight game as he has excelled after Odell Beckham Jr., Brandon Marshall and Dwayne Harris were all lost for the season. Engram has five TD catches, tying the Giants record for a rookie tight end set by Bob Tucker in 1970.

GO DEEP

The 49ers used the deep pass to great success with the 83-yarder to Goodwin the longest TD pass for San Francisco since Tim Rattay and Brandon Lloyd connected on an 89-yarder on Sept. 25, 2005, against Dallas.

ANTHEM PROTEST

Three players took a knee during the national anthem. Goodwin and Eric Reid protested for the 49ers while Vernon was the only Giants player to do it. No one else kneeled during the afternoon games on Veterans Day weekend.

''Our protest is against systemic oppression like we always say,'' Reid said. ''I didn't feel the need to stand today. I have a military background in my family. I've spoken to family members who don't feel disrespected.''

INJURIES

DT Damon Harrison (ankle), LG Justin Pugh (back) and LB Kelvin Sheppard (groin) left the game with injuries for the Giants.

UP NEXT

Giants: Host Kansas City on Sunday.

49ers: Host Seattle on Nov. 26.

---

For more NFL coverage: http://www.pro32.ap.org and http://www.twitter.com/AP-NFL

Copyright 2017 by STATS. Any commercial use or distribution without the express written consent of STATS is strictly prohibited.