Washington starting pitcher Max Scherzer celebrates after toying a major league strikeout record at 20 in the Nationals’ 3-2 win over the Tigers. (John McDonnell/The Washington Post)

With two outs in the top of the ninth of a one-run game, a major league record-tying 20 strikeouts already in the books, Max Scherzer threw strike one past Detroit Tigers catcher James McCann. Scherzer immediately started thinking about what might follow to get strikes two and three — high fastballs, sliders away, or any of the wide variety of pitches he threw wherever he wanted Wednesday night as he made history.

Strike two never came because McCann grounded Scherzer’s next pitch to Anthony Rendon, who threw to second for the final out of a 3-2 Washington Nationals win. Scherzer threw his right hand in the air and hugged catcher Wilson Ramos, beaming as he gained admittance to an exclusive three-man club of pitchers to strike out 20 in a nine-inning game. Its only other members: Roger Clemens and Kerry Wood.

“That’s some serious company. It won’t sink in right now,” Scherzer said. “But it’s an amazing accomplishment, especially to be able to get the win tonight. This will be the only time I’ll talk about giving up two home runs and have this big a smile on my face.”

Both Detroit runs came via home runs. The Tigers managed only four other hits as Scherzer threw an astonishing 96 of his 119 pitches for strikes, making for a ball-to-strikeout ratio of nearly 1 to 1.

The game began as a much-anticipated matchup of familiar aces facing their former teams as Scherzer, a former Tiger, battled former National Jordan Zimmermann. It quickly evolved into one of the more brilliant pitching performances in Nationals history, Scherzer’s most impressive outing of the season, a performance in which he shook off a seven-run battering in his last start to look as dominant as he has since his no-hitter last September.

“That’s incredible stuff,” Nationals General Manager Mike Rizzo said. “That’s such focus and competitiveness and stuff and heart. Every adjective you can imagine. You couldn’t have gotten him off that mound with a crane.”

Scherzer said he began his outing missing spots, but missing high with his fastball. Stephen Strasburg had told him he had success throwing the powerful Tigers lineup high fastballs like those, so Scherzer kept that in the back of his mind as he progressed through the lineup.

Nationals second baseman Daniel Murphy, who was on the other side of Scherzer brilliance with the New York Mets last September, said when he saw the Tigers begin swinging and missing at fastballs with late life, he figured Scherzer may be on to something.

“The first inning I ran in and I said to [Jayson Werth], ‘That’s Max,’’’ Bryce Harper said. “That’s the guy that goes out there and competes . . . he’s an animal out there.”

Scherzer played five seasons for the Tigers, went to the World Series and won a Cy Young award there. He has particular admiration for former teammate Miguel Cabrera — most do, of course — able to recite the future Hall of Famer’s splits and season stats off the top of his head.

Scherzer struck Cabrera out on three pitches in the second: slider, fastball, fastball. He struck him out on three pitches in the third: curveball, fastball, fastball.

Washington Nationals pitchers Max Scherzer has nearly 60 dives under his belt and has traveled to Fiji, Mexico and the Caymans. (Max Scherzer)

Through six innings, Scherzer, recently inefficient, had thrown 77 pitches. Fifteen of them were balls. Jose Iglesias’s homer just over the wall in left was one of only two hits against him. But Zimmermann was holding the Nationals down, too.

Zimmermann won 70 games for the Nationals. Scherzer won 82 games for Detroit. When Scherzer signed his seven-year, $210 million deal with the Nationals in the winter of 2015, he effectively elbowed Zimmermann out of their long-term plans, making his departure in free agency inevitable.

When Zimmermann stepped to bat for the first time against his former teammate, in the third inning, the fans at Nationals Park finally saw a chance to thank him for his seven seasons there, and rose to their feet.

Zimmermann, typically uninterested in such ceremony, hastily stepped in the box, but cheering forced him to step out again. He waved his helmet briefly to the crowd, which roared when he did so. Then he stepped back in the box and struck out.

“I didn’t like the standing ovation the fans gave him, because he was going to pitch against us,” Harper said with a smile. “But he deserves that.”

Less friendly than their fans, the Nationals greeted Zimmermann with three hits in the first from Rendon, Harper and Murphy. Murphy drove in the Nationals’ second run with a single off Zimmermann in the sixth, and he finished the night with three hits, his 18th multi-hit game in 33 starts, hitting .409. Danny Espinosa homered in the seventh.

So Scherzer led heading to the seventh, where he hit trouble for the first time. After Cabrera lined out, Victor Martinez singled and Justin Upton doubled to put runners on second and third with one out and a one-run lead. Needing strikeouts more than ever, Scherzer struck out catcher McCann looking at a fastball. Then he struck out Anthony Gose, one of two lefties in the Tigers’ lineup, on a 2-2 change-up to escape the trouble.

On he went to the eighth, with records in play and a lead to hold. He struck out Iglesias, one of two Tigers starters he had not yet victimized, to set a Nationals Park record with 16 strikeouts. He struck out pinch hitter Jarrod Saltalamacchia for No. 17, tying the career high he set in his no-hitter against the Mets last year. Then he struck out Ian Kinsler, tying Bill Gullickson’s Nationals/Expos single-game record and sending himself to the ninth with 106 pitches and the heart of the Tigers’ order looming.

J.D. Martinez homered on the first pitch of the inning. Manager Dusty Baker stuck with Scherzer. Up came Cabrera. Down he went, swinging through a 98-mph fastball, the hardest pitch Scherzer threw all night. With it, he set a franchise record, 19 strikeouts.

Then came Victor Martinez, the lone holdout against Scherzer’s strikeouts. He singled to left. Baker stuck with Scherzer, at 114 pitches, to face Upton. He struck him out. Twenty. The fifth major league pitcher to strike out so many (Tom Cheney of the Washington Senators struck out 21 in an extra-inning game in 1962, and Randy Johnson had 20 in 2001 in a 10-inning game). Then McCann grounded out to end it, one short of a major league record.

“The win was the most important thing tonight, especially to get a complete game,” Scherzer said. “That’s an accomplishment. The strikeouts are sexy, and that just makes it special, and the 20 really puts a stamp on it.”