Kwang Hyun Kim pitched seven scoreless innings, Matt Carpenter hit a two-run triple in the seventh for the first runs of the game and St. Louis snapped San Francisco's three-game winning streak by beating the Giants 5-3.
Kim (3-5) allowed three hits with two strikeouts and two walks.
Donovan Solano and Steven Duggar hit RBI singles in the ninth against Alex Reyes, but San Francisco's comeback bid fell short.
Gausman didn't allow a hit until Nolan Arenado's one-out single in the seventh that started a two-run rally in what had been a scoreless game. After Yadier Molina struck out, Tommy Edman singled before Carpenter's triple.
Arenado, an NL All-Star, added an RBI single in the eighth.
Adam Wainwright (6-5, 3.49 ERA), who has allowed two or fewer runs in five straight starts, pitches in San Francisco for the first time since a 5-2 loss on Sept. 19, 2016. The Giants counter with RHP Johnny Cueto (6-4, 4.00), looking to bounce back from a loss at Arizona.