WASHINGTON -- Gio Gonzalez said he has not changed much about his pitching approach in his last six games.
But one switch has been his teammates have provided more offense, and that was the case again Friday night.
The Nationals had only six hits but that included two home runs and a double as Washington beat the slumping San Francisco Giants 5-1 in a battle of first-place teams. Gonzalez gave up just two hits and one run in seven innings.
"It is a little bit less pressure," Gonzalez said of pitching with a lead. "Our offense will come through big time. We had some great plays defensively. With this rotation I am trying to keep up with the rest of the guys."
After giving up 15 runs in three starts through late June, the veteran lefty yielded just 10 runs in his last six outings.
"He's a good pitcher and he pitched well," said Bruce Bochy, the Giants manager. "He kept us off balanced. That was a well-pitched game."
The Nationals (65-44), who are 21 games over .500 for the first time this year, began the day seven games ahead of the second-place Miami Marlins in the National League East.
The Giants (62-47) started the night two games ahead of the second-place Los Angeles Dodgers in the National League West. San Francisco is 5-14 since the All-Star break.
"We have to find a way to get this offense going," Bochy said. "We have to bust out of this. It better be sooner than later. We have our work cut out tomorrow" against Stephen Strasburg, who is 15-1.
Wilson Ramos, who had two RBIs, hit a solo homer off starter and loser Jeff Samardzija (9-8) in the sixth to give the Nationals a 5-1 advantage. The Giants right-hander gave up six hits (including two homers) and five earned runs in seven innings before George Kontos pitched the eighth.
Gonzalez (7-9) had seven strikeouts and just one walk as he threw 104 pitches -- 67 for strikes. He had walked at least two batters in his previous six starts.
Lefty Sammy Solis pitched the eighth for the Nationals and allowed two hits with two outs before getting Denard Span on a grounder to end the threat. New Washington closer Mark Melancon pitched a perfect ninth in a non-save situation to nail down a crisp, quickly played win as he retired Buster Posey for the last out.
"That lead wasn't that big," Washington manager Dusty Baker said of using Melancon. "They had some dangerous guys coming up in the ninth."
Washington's Jayson Werth had a single in the first to extend his on-base streak to 36 games. That ties the best in the majors this year, equaling that of Marcell Ozuna of the Miami Marlins.
"Jayson is a veteran. He knows how to play," Baker said. "He has been very valuable in the two hole."
Bryce Harper followed with an infield single, and Werth went to third on a throwing error by shortstop Brandon Crawford. Daniel Murphy drove in a run with a single and Wilson Ramos made it 2-0 with a sacrifice fly to right.
Harper made it 3-0 in the third with a sacrifice fly to right that scored Turner, who led off with a bloop double to right and took third on a Werth flyout.
The Giants pulled to within 3-1 in the fourth on a solo homer by Angel Pagan.
Turner hit his second homer of the year and third of his career -- a solo shot in the fifth -- to give the Nationals a 4-1 lead. It was his first homer at Nationals Park.
"He looks like a kid but he plays like a man," Baker said of Turner.
Washington starter Gonzalez entered the game 4-3 with a 3.14 ERA in 10 career starts against the Giants. His last appearance came July 31 at San Francisco when he gave up two hits and one run in six innings in a 3-1 loss.
Samardzija, the Giants starter, lost his previous two starts and has not won on the road since June 17 at Tampa Bay. He went six innings and gave up four runs in a 4-1 loss on July 29 at home to Washington.
"He was real close to having a quality start," Bochy said. "Overall I thought he did alright."
NOTES: Giants 1B Brandon Belt got the night off from the starting lineup as Buster Posey made the start at first. ... Washington 1B Ryan Zimmerman (bruised left wrist) did not start and was not available off the bench, manager Dusty Baker said. Zimmerman was hit by a pitch last weekend in San Francisco. ... Washington OF Bryce Harper entered Friday hitting .115 in his last 15 games and .194 in his last 30. Harper was the unanimous MVP in the National League last season. ... Nationals RHP Stephen Strasburg (15-1, 2.69 ERA) will face Giants RHP Matt Cain (3-6, 5.53) on Saturday in the second game of the series. ... The Giants entered Friday with a 5-13 record since the All-Star break, even after a 3-2 win in 10 innings on Thursday in Philadelphia. Giants CF Denard Span, who played for the Nationals from 2013 to 2015, hit the winning homer in the 10th. ... Former Giants and Nationals OF Nate Schierholtz, a minor league free agent, was suspended 80 games Friday for taking a growth hormone. "That's a shame. I did get the news. I feel bad," Giants manager Bruce Bochy said. Schierholtz last played in the majors with the Nationals in 23 games in 2014.