The game-winning blast off Nationals closer Henry Rodriguez (1-2) came after Alex Presley had collected a one-out, pinch-hit single and advanced to third on a pair of wild pitches.
The decision went to Tony Watson (2-0), who followed Hanrahan to close out the half-inning.
Bucs starter A.J. Burnett tossed eight solid innings, striking out 10 while allowing a pair of runs on six hits.
Wilson Ramos homered for the Nationals, who dropped the opener of a three-game set at PNC Park.
Administration delays decision on Keystone XL once more
Rosie O'Donnell unveils nearly 50-pound weight loss