SAN FRANCISCO (AP) — Fernando Tatis Jr. hit his NL-leading 39th home run and the San Diego Padres beat the San Francisco Giants 7-4 on Thursday to earn a series split.

The Padres moved within half a game of the idle Cardinals for the second NL wild card at 76-70. San Diego starts a three-game series in St. Louis on Friday.

Tatis also singled and walked twice a day after matching a career best with four hits. Tommy Pham and Manny Machado each drove in two runs, and Adam Frazier and Austin Nola had three hits apiece.

“It feels good, especially the way we played the last couple of days,” Padres manager Jayce Tingler said. "Pitchers have been huge and, obviously, you’ve seen the shift offensively.”

Evan Longoria homered for the NL West-leading Giants, whose lead over the Dodgers dropped to a game. Los Angeles was off Thursday.

Nabil Crismatt (3-1) pitched four scoreless innings in relief to earn the win in a bullpen game for the Padres.

“He’s been kind of the secret guy at the back end that just continues to get the job done,” Tingler said. “Four innings against a really good lineup. He gave us exactly what we needed.”

Added Crismatt: "I’ve been feeling really well with all of my pitches right now. I feel really confident and just go out there and compete and have fun.”

Giants starter Kevin Gausman (14-6) lost for the first time since July 30, allowing four earned runs on eight hits in five innings.

“The Padres are swinging the bats very well the last couple of days,” San Francisco manager Gabe Kapler said. “I think we can chalk it up to kind of running into the best version of them.”

Trent Grisham gave San Diego an early lead when he drove in Frazier on a sacrifice fly in the second inning. Tatis homered to left in the third to make it 2-0. Pham provided some extra cushion in the fifth with a two-run double to right.

San Francisco got on the board in the sixth when Kris Bryant scored from third on a wild pitch by San Diego reliever Austin Adams.

LaMonte Wade Jr. doubled home Tommy La Stella in the seventh to cut the Padres’ lead to 4-2.

San Diego answered with three runs in the eighth on a pinch-hit RBI double by Wil Myers and a two-run single by Machado to make it 7-2.

Longoria launched his 13th home run of the season in the bottom of the eighth. Wade scored on a wild pitch in the ninth.

STREAK EXTENDED, STREAK SNAPPED

Longoria’s homer marked San Francisco’s 11th straight game with a long ball, tied for its longest streak of the season. However, the Giants failed to score at least six runs for the first time since Sept. 4, ending a stretch of 10 consecutive games, the longest in club history.

TRAINER’S ROOM

Padres: INF Jake Cronenworth missed his sixth straight game with a fracture in his left ring finger, but San Diego remains hopeful that he can return this weekend.

Giants: OF Mike Yastrzemski was held out of the starting lineup again after getting hit by a pitch on the right elbow in Tuesday’s game, but he pinch-hit for the second straight day. He struck out swinging in the fifth. ... LHP Alex Wood is nearing a return from the COVID-19 injured list and might pitch this weekend. “I think there’s a good chance that he can go for us Saturday,” Kapler said. “We’re not through the finish line yet, but I think that’s a good, strong possibility.” ... INF Donovan Solano (COVID-19 IL) could be activated Friday.

ROSTER MOVE

The Giants recalled LHP Sammy Long and optioned RHP Jay Jackson to Triple-A Sacramento.

UP NEXT

Padres: RHP Vince Velasquez (3-6, 5.95 ERA) will make his Padres debut on Friday when San Diego opens a three-game series in St. Louis. Velasquez signed a minor-league deal with the club on Wednesday after being released by the Phillies.

Giants: RHP Logan Webb (10-3, 2.80 ERA) will take aim at his 10th straight win on Friday night when San Francisco welcomes the Atlanta Braves for a three-game series.

—-

More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP_Sports