San Diego won the first two games of the four-game series after losing three straight.
St. Louis lost a season-high fourth straight home game but the Cardinals are still a major league-best 29-11 at home.
Gyorko hit a 3-2 pitch from closer Trevor Rosenthal (1-1) to bring in Yangervis Solarte, who hit a one-out triple.
Joaquin Benoit (5-3) picked up the win in relief.
Craig Kimbrel recorded his 21st save in 22 opportunities. He got Jason Heyward to ground into a game-ending double play.