Locke (2-1) yielded just two hits and a pair of walks as the Pirates reeled off their fourth victory in five games.
Jason Grilli struck out two batters in the ninth inning en route to his eighth save of the season.
Phillies starter Cole Hamels (0-3) pitched well in the loss, allowing two runs on seven hits and a walk over eight innings. The left-hander struck out six.
Duggar sisters unveil Christian dating rules in new book
McPhee, Cokas 'working on their marriage' after affair