Los Angeles Chargers tight end Hunter Henry (86) prepares to make a touchdown catch on a pass from quarterback Philip Rivers, not pictured, as New York Giants strong safety Landon Collins (21) defends during the second half of an NFL football game, Sunday, Oct. 8, 2017, in East Rutherford, N.J. (AP Photo/Bill Kostroun)

EAST RUTHERFORD, N.J. (AP) — The Los Angeles Chargers finally grabbed a win, while the New York Giants just about lost everything.

Philip Rivers threw a 10-yard touchdown pass to Melvin Gordon with 2:58 to play and the Chargers rallied for a 27-22 victory Sunday in an ugly game between teams that each went 0-4 in the first month of the season. For New York, it was a fifth straight defeat, and dynamic wide receiver Odell Beckham Jr . departed with a broken left ankle.

The worst of all was the injury to Beckham on the series before the Chargers’ winning touchdown. He jumped to catch a high Eli Manning pass and had Los Angeles cornerback Casey Hayward pin his ankle making a tackle. Players immediately signaled the sideline and Beckham was eventually carted off in obvious pain with a hand covering his face.

The touchdown pass was Rivers’ third of the game and came three plays after Kyle Emanuel had a sack, forced fumble and recovery against Manning at the Giants 11-yard line. It also came four plays after Beckham became the fourth Giants receiver knocked out of the game.

“We found a way,” said Chargers coach Anthony Lynn after his first win. “We’ve been looking for a way to win close games and we found a way. Now we’re going to enjoy this one, and tomorrow we’ll work on what that lesson really was.”

Rivers also hit Gordon on a 6-yard TD pass in the second quarter and had a 25-yarder to tight end Hunter Henry in the third as the Chargers ended a nine-game losing streak dating to late November.

The loss was the sixth straight for the Giants, who also lost to the Packers in the wild-card playoff game last season.

“I’m hurting right now. It’s a tough loss,” guard Justin Pugh said after the Giants were beaten for the third straight time late in the fourth quarter. “We will bounce back. We will go out and flush it. We’re still professionals. This is still our job. We have to go out there and execute, get this thing done.”

Manning had given the Giants a 22-17 lead early in the fourth quarter with a 48-yard TD pass to a wide-open Beckham. New York missed the 2-point conversion attempt after being hit with a delay-of-game penalty.

Manning, who was sacked five times, also threw a 29-yard touchdown pass to backup Roger Lewis Jr. in the third quarter. Orleans Darkwa scored on a 23-yard run and the Giants got a safety in scoring their first first-quarter points this season.

Manning’s attempt to rally the Giants in the final minute ended when he was intercepted by Tre Boston at the Los Angeles 33. On the drive New York used three tight ends and its only remaining receiver, Lewis.

Giants cornerback Eli Apple said he has never played in a game at any level where a team has lost four wide receivers.

“It was insane,” he said. “Did we even have any more receivers? I thought I was going to have to go out and play receiver.”

This game was filled with errors and there were a combined 21 penalties. Rivers (21 of 44 for 258 yards) and Manning (21 for 36 for 183) each missed open receivers deep. The Giants got a safety on a play when Chargers center Spencer Pulley snapped the ball from the 7-yard line before Rivers was ready, forcing the quarterback to toss the ball out of the end zone. Each team converted a PAT that hit the upright and bounced the right way. Referee Jeff Triplette announced “San Diego” on a call.

WR MISERY: Giants WRs Sterling Shepard and Brandon Marshall left on the same second-quarter series with sprained left ankles. Dwayne Harris broke a foot on a kickoff return in the third quarter. Beckham was the final one.

INJURIES: After playing in 84 straight games, Giants DE Olivier Vernon (ankle) was sidelined for the first time in his career. New York C Weston Richburg (concussion) had started the last 26 games … Chargers starting LB Korey Toomer did not suit up because he was not able to play on special teams.

NOTES: The Giants did not give up a sack last week in a loss to the Buccaneers. Joey Bosa and Emanuel each had two. Darius Philon had the last one. … Giants S Darian Thompson had a team-high 11 tackles and his first career interception.