Trailing 4-3 in the eighth, Cristian Guzman started the decisive rally with a one-out single off Tom Gorzelanny (1-1) and moved to second on Nick Johnson's single to center. Zimmerman followed with a tying single to right, the 39th straight game he has reached base safely. Dunn put Washington ahead with the fourth straight single of the inning.
Julian Tavarez (1-3) got the victory with 1 2-3 innings of scoreless relief. Joel Hanrahan got three outs for his fourth save in seven opportunities.
LaRoche homered for the Pirates, who had won five straight.
Josh Bard had two RBIs for Washington.
The Nationals staked Stammen to a 2-0 lead in the second. Josh Willingham drew a leadoff walk and moved to third when Willie Harris doubled to right. Bard's grounder scored Willingham and Anderson Hernandez followed with a sacrifice fly.
In the fourth, Bard's two-out single up the middle made it 3-0, scoring Willingham, who had doubled down the left-field line.
Pittsburgh cut the lead to 3-1 in the fifth. LaRoche doubled to lead off the inning, moved to third on Brandon Moss' grounder and scored on a bouncer to short by Andy LaRoche.
Adam LaRoche's seventh homer tied the game in the seventh. Nate McLouth walked and LaRoche ripped a 2-2 fastball into the second deck in right field.
Andy LaRoche followed with a run-scoring single to center, giving the Pirates a 4-3 lead and chasing Stammen.
Stammen allowed four runs on four hits in 6 1-3 innings. He walked one and struck out three.
Pirates starter Ian Snell allowed three runs on four hits, walked one and struck out six.
Notes: Andy LaRoche has 10 hits and nine RBIs in his last 22 at-bats. ... Hernandez left the game with sprained pinky finger on his right hand after grounding out to end the fourth. He was replaced at second base by Ronnie Belliard. X-rays were negative and Hernandez is day to day. ... Pittsburgh was bidding for its first six-game winning streak since May 6-12, 2008. Pittsburgh's was denied its first four-game sweep since May 29-June 1, 2006, over Milwaukee at PNC Park.