A crowd of 18,029 attended the first game at Nationals Park without capacity limits since the 2019 World Series.
Scherzer, a 36-year-old right-hander with three Cy Young Awards, retired leadoff batter LaMonte Wade Jr. on a fly ball to left and had a 3-2 count on Brandon Belt when he stretched his body, and manager Dave Martinez and director of athletic training Paul Lessard went to the mound.
Scherzer took one warmup toss before exiting. Scherzer is 5-4 with a 2.21 ERA and began the night second in the NL with 104 strikeouts.
"All of a sudden I felt my groin tweak me," Scherzer said.
"The good news is that it is not a muscle strain. I am really day-to-day. I am very confident this will be very mild."
Scherzer said an MRI showed only inflammation.
"It was a lot better news than I thought," Nationals manager Dave Martinez said. "We're still not out of the woods. We'll see how he feels tomorrow."
DeSclafani (6-2) struck out eight and walked one in his third career shutout and complete game. He pitched a four-hitter for Cincinnati at Arizona in August 2016 and a three-hitter against Colorado this April 26.
San Francisco pitched its major league-leading ninth shutout. The Nationals have been blanked eight times.
Mike Tauchman leaped at the left field wall to rob Juan Soto in the seventh.
"That was insane - huge catch," DeSclafani said. "If you don't make that it's a tie ballgame and I probably don't go nine."
On May 28 at Dodger Stadium, Tauchman took away what would have been a game-winning home by Albert Pujols in the ninth inning, and the Giants went on to beat Los Angeles in the 10th.
DeSclafani retired his first nine batters before Trea Turner singled leading off the fourth. Josh Bell doubled with two outs in the seventh off DeSclafani, who faced only one more than the minimum 27 batters. DeSclafani has allowed three earned runs or fewer in 16 consecutive road starts.
Posey homered in the fourth, driving a slider from Paolo Espino (0-2) into the Giants bullpen in left for his 11th homer this season.
Posey, who opted out of the 2020 season during the pandemic, already has more homers than he did in both 2018 and 2019. His career high is 24 homers which he set in 2012 when he was voted MVP.
Espino, who entered on short notice after the Scherzer injury, struck out five in 3 1/3 innings while allowing one run on three hits. Five Nationals relievers combined to allow four hits and retired their final 16 batters.
"What stands out to me was how well the Nationals bullpen and Davey navigated that game without Scherzer," Giants manager Gabe Kapler said. "Obviously, you never want to see anyone get hurt on the mound."
"It's crazy," Tauchman said of his catch. "The opportunities are few and far between for those. Any time the fence is involved there's a certain level of difficulty. At that point it was an important play in the grand scheme of the game."
Giants: Kapler said C Curt Casali (left wrist strain) and OF Mike Yastrzemski (right thumb sprain) should both be reinstated from the 10-day injured list on Saturday. ... 1B Darin Ruf (right hamstring strain) could return as soon as the Diamondbacks series that begins on Monday. ... LHP Caleb Baragar (left elbow inflammation) was reinstated from the 10-day injured list.
Nationals: RHP Stephen Strasburg (neck) came in for a workout Friday and left before the game started. "It's frustrating for him, I know," Martinez said about Strasburg, who has only pitched 21 2/3 innings over five games this season. ... RHP Austin Voth (nose fracture) has seen the swelling in his eye go down, according to Martinez. Voth was able to ride a bike and throw a baseball from a short distance.
Giants RHP Kevin Gausman (7-0, 1.27 ERA) is unbeaten in 12 starts and takes an NL-best 1.27 ERA into Saturday, when is expected to start a doubleheader opener against Erick Fedde (4.35), who has been on the COVID-19 injured list since May 19.
Scherzer exits game with arm discomfort in 1st inning
Max Scherzer throws 12 pitches before having to leave the game with arm discomfort vs. the Giants.