SAN FRANCISCO — The Washington Nationals made history by turning the first 3-3-5 triple play ever in the major leagues then watched as third baseman Anthony Rendon tossed the ball from the milestone moment into the crowd at AT&T Park.

Getting a second straight win over the Giants and securing their hold on the second-best record in baseball was far more important than the souvenir to manager Dusty Baker and his ballclub.

Washington turned the first triple play in its 12-season history, holding on in the eighth inning to help preserve a strong outing by Max Scherzer and beat San Francisco 4-1 on Friday night.

"Crazy," Zimmerman said. "Couldn't have happened at a better time for us. Great job by Sammy (Solis) coming in and getting two pitches and three outs."

The Giants loaded the bases in the eighth with two walks sandwiched around a single. Brandon Crawford then lined an 0-1 pitch from Sammy Solis to first baseman Ryan Zimmerman, who had entered the game moments earlier as a part of a double switch.

Zimmerman quickly stepped on first base for the second out then threw to third baseman Anthony Rendon to catch Denard Span to complete the triple play.

"Once I caught it I knew I had the double play," said Zimmerman, who was moved a few steps back before Crawford swung. "Then Tony was jumping up and down with a smile on his face so I just tossed the ball over to him. Got out of a jam just like that."

It was the first 3-3-5 triple play in history, according to Sabr.org, and alos the first Baker has ever seen as a player or manager.

"There was one other one but I went to the bathroom and missed it," Baker said.

Scherzer (11-6) had lost four of his five career starts against the Giants and a no-decision in Game 4 of the 2012 World Series before holding San Francisco to one run over seven innings.

The four-time All-Star retired 14 of the final 16 batters he faced and finished with six strikeouts and two walks.

Over his last six starts Scherzer has allowed just five earned runs in 41 1/3 innings.

"Once we got that lead he knows how to smell the finish line," Baker said. "Max was awesome."

Four relievers combined to retire eight batters.

Four players had two hits apiece for the Giants. San Francisco fell to 2-11 since the All-Star break.

San Francisco put two runners on base in the ninth but Shawn Kelly struck out Eduardo Nunez — making his Giants debut — for his sixth save.

"We're just having a hard time getting runners in," Giants manager Bruce Bochy said. "It's a tough go but you have to be big boys and come out here and put your big boy pants on and keep fighting. That's all you can do."

Jayson Werth had two hits for the Nationals to extend his on-base streak to 32 games, tied with Boston's Dustin Pedroia for the longest active streak in the majors, and Ben Revere hit a tiebreaking single in the fifth.

Daniel Murphy added an RBI triple while Wilson Ramos doubled and scored to help the Nationals win their second straight in this four-game series between division leaders.

All of Washington's runs came off Giants starter Jeff Samardzija (9-7).

FAN CHARGES FIELD

The game was interrupted in the top of the seventh inning when a fan ran onto the field. The man avoided security guards for a few moments then dropped to one knee near Giants SS Crawford before being tackled and escorted away.

TRAINER' S ROOM

Nationals: Backup C Jose Lobaton was placed on the 15-day disabled list with left elbow tendinitis. The move is retroactive to July 20. ... Pedro Severino was called up from Triple-A Syracuse.

Giants: Nunez, obtained a day earlier in a trade from Minnesota, was added to the 25-man roster and was in uniform. To make room, OF Jarrett Parker was optioned down to Triple-A Sacramento. ... 3B Matt Duffy (left Achilles strain) took infield and ran the bases before the game in anticipation of beginning a rehab assignment.

UP NEXT

Nationals: RHP Reynaldo Lopez (0-1) will be called up from Syracuse to face San Francisco on Saturday. Lopez lost in his major league debut against the Dodgers on July 19.

Giants: RHP Jake Peavy (5-9) will make his 14th career start against the Nationals franchise. Peavy's first came during his rookie season of 2002 against the then-Montreal Expos.