Mike Yastrzemski also homered off Szapucki, a 25-year-old left-hander making his first major league start and second appearance after the Mets summoned him from the minors due to a string of injuries.
New York lost two of three in San Francisco, the Mets' second series loss in their first 14 series this season. New York had won its previous 14 games following a loss, the third-longest such streak in major league history behind the 1934 New York Giants (16) and 1911 Philadelphia Athletics (15).
The Mets also lost consecutive games for the first time since April 10 and 11. New York overcame an 8-2 deficit Tuesday to take leads of 11-8 and 12-11 before losing 13-12. That was the Mets' first loss in the 181 games in their history in which they scored 12 runs or more.
"That's a playoff team right there," Longoria said of the Mets. "I think we're all happy with the result."
Szapucki, who had been at Triple-A Syracuse, got the start because of injuries to Jacob deGrom, Max Scherzer and Tylor Megill. Szapucki allowed nine runs, seven hits and three walks in 1 1/3 innings, leaving him with a 60.75 ERA this season and a 27.00 ERA in his career. His only previous big league appearance was last June 30, when he gave up six runs and seven hits over 3 2/3 innings during a relief appearance in a 20-2 loss at Atlanta.
Szapucki threw just 23 of 49 pitches for strikes.
"Never could get into a rhythm," Mets manager Buck Showalter said. "Command was an issue. You know he wanted to do well with the opportunity that he had. They were on about everything he threw."
Following Chris Bassitt's poor outing Tuesday, Mets pitchers allowed eight runs in consecutive games for the fourth time after Jonathan Niese and Bartolo Colon in 2015, Dillon Gee and Niese in 2011 and Rick Reed, Al Leiter and Bobby J. Jones in 1999.
Mets left fielder Jeff McNeil, slid face first into the low fence in left field foul territory after catching Donovan Walton's third-inning fly. McNeil bruised his left knee when hitting the wall, left for a pinch hitter in the fourth.
"Precautionary," McNesaid of his removal. "Feel good. Ready to go on Friday."
Longoria, limited this season by a right hand injury, had four RBI with his first two home runs of the season. He put the Giants ahead with a three-run homer in the first and followed Yastrzemski in the second with the Giants' second back-to-back homers this year, boosting the lead to 9-0.
Former Met Wilmer Flores had an RBI double in the second, driving in the Giants' only run that didn't score on a homer.
Pederson, who hit three homers and had eight RBI on Tuesday, made it 5-0 in the second with his 11th home run this season. Pederson was given a rare start against a left-hander.
"That was just strictly self-preservation on my part," Giants manager Gabe Kapler said before the game. "I'm all good with trying to get the platoon advantage wherever possible but I also want to survive the day."
Jakob Junis (2-1) gave up two runs and three hits in six innings, throwing just 16 fastballs among 86 pitches. By altering velocities with his changeup and slider, Junis "created a guessing game in the hitters' minds," according to Kapler.
Francisco Lindor doubled and homered off Junis. He is 20 for 39 (.513) against him with six home runs.
San Francisco's Darin Ruf struck out four times - all in the first six innings
The Mets' Aug. 7 home game against Atlanta was moved from 1:40 p.m. to 4:10 p.m. after a game against the Braves postponed by the lockout was rescheduled as part of a day-night doubleheader the previous day.
Mets: Optioned RHP Steve Nogosek to Triple-A Syracuse to open a roster spot for Szapucki, who was recalled from the Triple-A farm team. New York acquired OF Daniel Johnson from Cleveland for cash and assigned him to Syracuse.
Giants: Walton was recalled from Triple-A Sacramento to give Brandon Crawford a day off. Walton went 1 for 3.
Mets: RHP Carlos Carrasco (4-1, 3.50) starts Friday night's homestand opener against Philadelphia.
Giants: LHP Carlos Rodón (4-3, 3.43) is to be on the mound Friday at Cincinanti for the start of a 10-game trip.
Joc Pederson stays hot with 4th HR in 6 ABs
A day after hitting three home runs, Joc Pederson homers in his first at-bat against the Mets.