Locke (9-2) allowed only a lead-off single to Shin-Soo Choo in the first, then controlled the Reds on four walks the rest of the way. The left-hander struck out six before exiting with the game tied 1-1.
The Pirates then struck for a pair of runs against Cincinnati starter Homer Bailey in the seventh.
Mike McKenry bashed a one-out double and Mercer followed with a base hit to center field, sending home the go-ahead tally.
Bailey (5-9) absorbed the loss, striking out 12 but surrendering three runs on seven hits over 6 1/3 frames.