The San Diego Padres can have a say over the NL West race even as they appear headed toward what would be the biggest collapse in franchise history.

Jurickson Profar raced home on Victor Caratini's infield single with one out in the 10th inning and the Padres beat San Francisco 7-6 Thursday to tighten the NL West race between the Giants and the defending World Series champion Los Angeles Dodgers.

The Giants’ lead was trimmed to one game over the eight-time defending division champion Dodgers, who won 7-5 in 10 innings at Colorado. The Giants were denied a three-game sweep as well as their 100th win.

Caratini hit a grounder to diving second baseman Tommy La Stella, whose off-balance throw home was way off the mark. The winning rally off Dominic Leone (3-5) allowed the Padres to snap a five-game losing streak and stay above .500.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

Profar started the inning on second as the automatic runner. Trent Grisham was intentionally walked before Kim Ha-seong sacrificed. Caratini then walked it off.

The Padres spent much of the summer in control of the second wild-card spot before a devastating stretch this month left them reeling.

"We’re always looking for the edge, anything we can get, fighting, scratching, clawing until the end," Grisham said. "That’s what we’re going to keep doing until they say we can’t play anymore."

The Padres won for just the third time in 13 games and remained six games behind St. Louis for the second wild-card spot with 10 games to go. Cincinnati and Philadelphia entered Thursday 1 1/2 games ahead the Padres.

San Diego held a one-game lead for the second spot on Sept. 9 before going 2-8 on a trip through Los Angeles, San Francisco and St. Louis, and then losing the first two games of this series.

The Padres play three games against NL East leader Atlanta this weekend, as well as finishing a game that was suspended on July 21, before ending the season with three games at the Dodgers and three at the Giants.

"Our season’s on the line," Grisham said. "Everything's on the line, so it’s easy to stay engaged. We’re trying to get to the playoffs and win a World Series."

Asked about the daunting deficit, he added: "All that means is you’ve got to win. That's how we see it. That's how we’re going to continue to see it. We're going to continue to play hard.

La Stella walked to open the Giants' 10th before Ross Detwiler (3-1) retired Brandon Belt, Kris Bryant and Steven Duggar.

"Obviously it was disappointing to not have that 10th inning come out differently," Giants manager Gabe Kapler said. "I’m proud of the toughness our team showed today."

Starter Logan Webb lasted only four innings, taxing the bullpen heading into a weekend series at Colorado.

"There’s no discounting this was a challenging game to navigate on any number of levels," Kapler said. "We’d love to have a fresh bullpen going into Colorado, but that’s not the case. It’s not a foreign situation for us. We’ve been here before."

There were three lead changes from the sixth inning on.

Pinch-hitter Austin Slater hit a three-run homer off lefty reliever Tim Hill to give the Giants a 5-4 lead with one out in the sixth. It was Slater’s 11th homer of the season and San Francisco’s 17th pinch-homer of the year, tied for the most in baseball history.

With two outs in the bottom of the inning, Grisham and Kim hit consecutive homers off Jose Quintana for a 6-5 lead. It was Grisham's 15th and Kim's seventh.

The Giants came right back and tied it with two outs in the seventh on consecutive doubles by pinch-hitter Wilmer Flores and La Stella.

Yu Darvish was cruising with a 4-2 lead when he walked La Stella to open the sixth and allowed a single to Brandon Belt. Darvish struck out Kris Bryant and made way for Hill, who allowed Slater's shot to left.

The Padres staked Darvish to a 4-0 lead in the first before the right-hander allowed Mike Yastrzemski's two-run homer with two outs in the second, his 24th.

San Diego jumped on shaky Webb in the first inning for four runs on three hits, two walks, a hit batsman and a wild pitch. Profar was hit by a pitch with the bases loaded, Grisham hit a sacrifice fly and Kim and Caratini hit RBI singles.

It was the first time the Padres scored four or more runs in the first inning since Aug. 1 against Colorado.

Darvish allowed four runs and three hits in 5 1/3 innings, struck out seven and walked three. Webb allowed four runs and four hits in four innings, struck out three and walked two.

UP NEXT

Giants: LHP Alex Wood (10-4, 3.99) is scheduled to start the opener of a three-game series at Colorado. Rockies RHP Peter Lambert is set for his first start since Sept. 20, 2019 due to Tommy John surgery.

Padres: Begin a home series against the Braves by resuming a game that was suspended in the fifth inning July 21 in Atlanta with San Diego leading 5-4. The teams will then play the regularly scheduled game, with LHP Max Fried (12-7, 3.31) set to go for Atlanta. The Padres haven't named a starter.