Updated

With their season-best winning streak gone by the wayside the San Diego Padres focus on a series win Wednesday when they play the rubber match of a three-game series versus the San Francisco Giants at AT&T Park.

San Diego lost for the first time in eight games on Tuesday, as Juan Perez's RBI single in the bottom of the eighth inning lifted San Francisco to a 5-4 win.

The Padres scored twice in the top of the eighth to take a 4-3 lead. San Diego then sent Dale Thayer (0-3) to the mound in the bottom half. Buster Posey singled and was replaced by Andres Torres, who raced home on Brandon Belt's double off the wall in right-center field. Nick Noonan was intentionally walked before Joaquin Arias lined out. Perez then followed with the game- winning hit to right.

"He saved the game for us, he won the game for us," Giants manager Bruce Bochy said of Perez.

Sergio Romo tossed a scoreless ninth to pick up his 17th save of the season for the Giants, who snapped a three-game skid. Matt Cain got the start and gave up two runs on six hits while striking out 10 over seven innings. Jean Machi (2-0) recorded the final out in the eighth to get the win.

Belt went 3-for-4 with two runs scored for San Francisco. Gregor Blanco and Posey added an RBI apiece.

Jesus Guzman, Nick Hundley and Logan Forsythe homered for the Padres, who lost for only the third time in 10 games. Andrew Cashner allowed three runs on 10 hits while striking out six over 6 2/3 frames.

"That was a great baseball game," said Padres manager Bud Black.

Hoping to get the Padres back on track Wednesday will be lefty Eric Stults, who is 6-5 with a 3.28 ERA. Stults went the distance against the Arizona Diamondbacks on Friday to win his second straight start, as he gave up a run and two hits to improve to 6-5, while lowering his ERA to 3.28.

Stults is 4-3 in 13 games (11 starts) versus the Giants with a 5.34 ERA.

San Francisco, meanwhile, will counter with lefty Madison Bumgarner, who has won his last two starts. Bumgarner beat the Atlanta Braves on Friday, as he scattered two hits and struck out 10 over seven scoreless innings to run his record to 6-4 to go along with a 3.30 ERA.

"That was a masterful performance," Black said after the game. "They didn't threaten because Eric was outstanding. What you saw was a mix of pitches, any of which can be thrown for a strike. When Eric can do that, he's so tough. He can throw a fastball in the low 90s and a curve in the mid-60s. When you don't know what's coming, that's incredibly difficult to deal with."

Bumgarner has faced the Padres 14 times (13 starts) and is 4-3 with a 3.44 ERA.

San Diego has split eight games with the Giants this season, but it has lost 16 of 21 in the series as the visiting team. The Giants swept the Padres at AT&T earlier in the year, only to see the Padres return the favor in San Diego.