Hairston's sac fly lifts Nationals past Pirates in 11 innings, 6-5 (Video highlights)
Werth, who had missed the last five games with a bothersome shoulder, entered the game as a pinch-hitter in the ninth and doubled leading off the 11th against Brandon Cumpton (3-4).
Werth went to third on Denard Span's grounder to first. Hairston then sent Cumpton's first pitch to deep left and Werth scored easily after the catch.
Ross Detwiler (2-2) pitched two innings for the win.
Span and Anthony Rendon had two hits each for National League East-leading Washington, which has won six straight.
The Pirates have lost five straight for the first time since September 2012.
Both closers blew save chances in the ninth.
Trailing 4-2 entering the inning, the Pirates got one run on a wild pitch and took a 5-4 lead on Gregory Polanco's two-run double off Rafael Soriano.
Washington rallied against Matt Melancon in their half, however. Asdrubal Cabrera's one-out single off the glove of a diving Neil Walker scored Werth, who had walked, from second with the tying run.
Washington starter Doug Fister allowed two unearned runs while striking out five. He hasn't given up an earned run in his last 22 1-3 innings.
The Nationals trailed 2-1 before a successful challenge started a seventh-inning rally.
A pitch to Michael Taylor was called a foul ball by home plate umpire Andy Fletcher as Taylor started towards first. Manager Matt Williams challenged, saying the 2-1 pitch hit Taylor's hand, and the call was overturned upon review.
Pinch-hitter Kevin Frandsen and Span singled to load the bases. Cabrera, facing reliever Jared Hughes, grounded to first baseman Ike Davis. Davis threw high to home, the ball deflecting off Russell Martin's glove as Taylor scored.
As the ball rolled up the third-base line, Frandsen raced home as well, putting Washington ahead 3-2.
Rendon then grounded to Pedro Alvarez, who threw high to home for another error, allowing Span to score the Nationals' fourth run.
Errors by Washington's Ian Desmond and Rendon helped the Pirates take a 2-0 lead in the sixth.
The Nationals cut it to 2-1 in the sixth on Desmond's two-out RBI-single.
Nationals: RF Jayson Werth, who sat out the last five games due to a bothersome right shoulder, walked as a pinch hitter in the ninth and stayed in the game in right.
Nationals: Jordan Zimmermann (8-5, 2.92) opposes visiting Arizona in the first of four games. He is 2-0 with a 1.37 ERA in his last three starts.