Pinch hitter Tommy Edman supplied the game-winning single in the 10th for the Cardinals, who snapped a four-game losing streak.
St. Louis starting pitcher Zack Thompson allowed three runs (two earned) on five hits and four walks with three strikeouts in four innings. JoJo Romero (4-1) blanked the Padres for the final two innings to earn the victory.
Jose Azocar had two hits and two runs, Matthew Batten went 4-for-4 with a walk and two runs and Luis Campusano homered for the Padres, who lost for the fourth time in five games.
Padres starting pitcher Seth Lugo gave up three runs (two earned) on six hits and a walk in six innings. He fanned six. Josh Hader (0-2) pitched the 10th inning and took the loss.
San Diego's He-Seong Kim opened the game with a single. Juan Soto's bunt single and a throwing error sent Kim to third base, and Fernando Tatis Jr.'s sacrifice fly made it 1-0.
Jordan Walker and Masyn Winn hit singles to start the St. Louis third, but Walker was picked off second base on a botched bunt attempt. Paul Goldschmidt drew a two-out walk, and Nolan Gorman hit an RBI single to tie the game 1-1.
The Padres took a 3-1 lead in the fourth inning when Campusano walked with one out, Batten hit a double and Azocar's single drove them home.
The Cardinals got a run back in the bottom of the inning. Contreras reached on an error, took third on Alec Burleson's ground-rule double and scored on Walker's sacrifice fly.
Campusano's homer in the sixth inning increased San Diego's lead to 4-2, but Contreras cut the lead in half with a homer in the bottom of the frame.
San Diego increased its margin to 5-3 in the eighth inning. Batten hit a one-out double, moved to third on Azocar's single and scored on Kim's sacrifice fly.
The Cardinals tied the game in bottom of the inning on Goldschmidt's leadoff single and Contreras's two-out, two-run homer.
—Field Level Media