SANTA CLARA, Calif. (AP) Eli Manning threw a 3-yard touchdown pass to Sterling Shepard with 53 seconds left and the New York Giants snapped a five-game losing streak by beating the San Francisco 49ers 27-23 on Monday night.

''It meams a lot,'' Manning said. ''That's what I told the guys this week. We've worked too hard not to be rewarded with wins. ... We just weren't able to get some of the outcomes or make the plays we needed to win. Today we were able to do that.''

Manning threw two TD passes to Odell Beckham Jr. and then engineered the late game-winning drive with help from a pair of third-down penalties against Malcolm Smith and Ahkello Witherspoon.

Saquon Barkley then had a 23-yard catch to get the ball into the red zone and Manning connected with Shepard on third down to give the Giants (2-7) the win.

''I just saw man-to-man coverage,'' Shepard said. ''That's something we've been practicing. I was able to capture the outside edge and Eli put the ball in a perfect place.''

Matt Breida ran for 101 yards and scored two touchdowns for the 49ers (2-8), who were unable to win consecutive games under third-string quarterback Nick Mullens. Breida's 23-yard run helped set up a 30-yard field goal by Robbie Gould that gave the Niners a 23-20 lead with 2:46 to play.

But the 49ers allowed the go-ahead score and couldn't pull it out at the end as Mullens' pass from the Giants 20 sailed out of the end zone on the final play.

Mullens wasn't nearly as sharp as he was in his NFL debut against the Raiders on Nov. 1 when he joined Hall of Famers Jim Kelly and Fran Tarkenton as the only players with at least 250 yards passing, three touchdown passes and no interceptions in the first career game.

Mullens threw for 250 yards and had an 11-yard TD pass to Breida that made it 20-10 early in the third quarter. But Mullens also threw two interceptions with the first setting up a 10-yard TD pass from Manning to Beckham .

Those two connected again on a 20-yard score in the third quarter as New York rallied from 10 points down to tie the game in the second half.

HARD HIT

Niners receiver Marquise Goodwin was hit in the helmet by Alec Ogletree on a catch late in the third quarter and briefly left the game. On his first play back in to start the fourth quarter, a pass from Mullens deflected off Goodwin's hands for the second interception of the game by B.J. Goodson . Goodwin was slow to get up after that play and went back into the medical tent for observation. Goodwin returned to the game later in the fourth quarter.

MISSED OPPORTUNITY

The Giants entered the game converting just 40 percent of their red zone trips into TDs. They missed a golden opportunity for one late in the first half. On a third down from the 3, the 49ers left Beckham unguarded in the slot but Manning stuck with a run play to Barkley that gained only 1 yard. New York settled for a field goal that tied the game at 10.

The Niners then drove down for a late field goal to take the lead at the break as the Giants trailed at the half for the eighth time this season.

PLAYING FOR PARADISE

Niners GM John Lynch welcomed the high school football team from Paradise, a town destroyed by the wildfires in Butte County, about 175 miles north. Players and cheerleaders from the school were on the field for the national anthem. The air quality for the game was at an unhealthy level because of the fires.

The Air Quality Index was at 161 at kickoff, which is in the unhealthy zone, and smoke could be smelled throughout the stadium. The NFL had monitored the situation but the AQI never got near 200, the level where the game would have needed to be moved.

UP NEXT

Giants: Host Tampa Bay on Sunday.

49ers: Visit Tampa Bay on Nov. 25.

---

More AP NFL: https://apnews.com/NFL and https://twitter.com/AP-NFL

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