Updated

Washington, DC (SportsNetwork.com) - Wilson Ramos hit a walk-off double in the bottom of the ninth inning to lift the Washington Nationals to a 4-3 comeback win over the Pittsburgh Pirates in the middle test of a three-game set.

The Nationals trailed 3-0 before scoring three runs in the eighth to tie it and another in the ninth to win it.

Bryce Harper worked a walk against Justin Wilson (3-3) to lead off the ninth, advanced to second on a wild pitch and scored when Ramos ripped a ground-rule double over the head of Gregory Polanco in right to plate Harper.

"We have a lot of heart," said Harper. "We are trying to keep rolling for the next month and a half and really do things the right way."

Matt Thornton (1-0) struck out two in a 1-2-3 ninth to notch the victory.

Adam LaRoche smacked a game-tying, two-run homer in the eighth, while Kevin Frandsen went 3-for-4 with an RBI for Washington, which has won five straight and eight of its last 10 games.

Gaby Sanchez posted three hits and two RBI, Starling Marte tallied two hits, an RBI and a run scored and starter Jeff Locke struck out six and allowed four hits and two walks over 5 2/3 scoreless innnings for the Pirates, who have dropped four in a row.

"The fastball velocity was very good tonight," Pirates manager Clint Hurdle said of Locke. "He pitched well."

The Pirates plated all three of their runs in the third.

Josh Harrison hit a one-out single before being forced out following a Polanco grounder. Russell Martin worked a walk and Marte fisted a double down the left-field line to plate Polanco. Sanchez then rolled a base hit through the hole on the left side to bring home Martin and Marte.

Washington got all three of those runs back in the eighth.

Michael Taylor walked and Denard Span singled to put runners on the corners to start the eighth. Taylor came home on Frandsen's looper to right to cut the deficit to 3-1.

Tony Watson then got Rendon to ground into a 6-4-3 double play, but LaRoche cracked his two-run shot into the Nationals bullpen to right to tie the score.

Game Notes

It was Watson's first homer allowed to a left hander since June 13, 2012 when Chris Davis took him deep ... Washington was 3-for-8 with runners in scoring position, while Pittsburgh finished 2-for-4.