With the score knotted at 2-2 in the bottom of the 11th, Hector Sanchez (3-for-5) led off with a single against Joe Thatcher (3-2).
Adrianza came in to run for Sanchez, went to second on an out and scooted home when Pagan sent a hit into left field.
Javier Lopez (3-2) was credited with the victory after recording the final two outs in the top of the 11th as San Francisco earned a split in its four-game series.
Giants starter Madison Bumgarner hurled six shutout innings, yielding four hits and striking out nine.
Eric Chavez and A.J. Pollock each drove in a run for the Diamondbacks.
Beyonce flaunts bikini body, Blue Ivy in vacation pics
Kate Middleton recycles dress at movie premiere