Locke was one batter away from becoming the first Pirates starter to face the minimum in a shutout since John Candelaria on July 25, 1982. The attempt ended when pinch-hitter Jeff Mathis delivered a two-out single in the ninth.
In defeat, Marcell Ozuna's 11-game hitting streak was snapped, as was his string of reaching safely in 36 straight games.
Sean Rodriguez provided some extra cushion with a two-run homer in the ninth off Edwin Jackson. David Freese had four hits, with two doubles, two RBIs and two runs scored.