Anthony Rendon’s home run keyed a four-run sixth inning for the Nationals. (Nick Wass/Associated Press)

Wilson Ramos wasn’t scheduled to undergo an MRI exam on his right knee until Tuesday, but Dusty Baker was already preparing for a season-ending anterior cruciate ligament tear in his office at Nationals Park late Monday night. The Washington Nationals’ manager and Rick Schu, his hitting coach, were cycling through different lineup possibilities without Ramos’s all-star bat in the middle of the order. Chris Speier, Baker’s bench coach, later dropped in to say good night. When he did, there were 15 sheets of crinkled paper in a trash can. Each had a different lineup.

“That’s what I do,” Baker said.

Ramos’s ACL tear was confirmed early Tuesday afternoon. A few hours later, Baker’s six-game experimentation period in preparation for the postseason, a trial requiring a balancing act between playing for home-field advantage in the National League Division Series and keeping players healthy, began with a lineup that didn’t include Bryce Harper or Daniel Murphy. Both were out with less severe injuries, leaving the Nationals without three premier sluggers. But there was still enough power to fuel a 4-2 victory over the Arizona Diamondbacks with another strong performance from Max Scherzer.

After the Nationals failed to record a hit through five innings, Jose Lobaton, Ramos’s replacement, provided their first one of the night off Diamondbacks right-hander Matt Koch to spark a four-run rally in the sixth inning that Anthony Rendon concluded with a three-run home run into the visiting bullpen.

“It doesn’t matter if we’re getting shut out or no-hit all the way until the ninth inning with two outs,” Rendon said. “We still have a chance, so we were out there battling.”

As the ball cleared the wall, a giddy Baker walked over to Scherzer, who he removed for a pinch-hitter earlier in the inning after careful contemplation, to give him a high-five laced in four-letter words. Rendon’s home run not only put Scherzer in line for the win, his 19th of the season, but it kept Scherzer’s quest for 20 victories alive with one regular season start remaining. The milestone has lost its luster across the industry in recent years and it isn’t high on Scherzer’s list of goals, but its importance to Baker was evident and Scherzer matched his boss’s elation.

“Dusty was out of his mind,” Scherzer said. “If there’s anybody that’s going to lose their mind, I’ll lose my mind with you.”

Sammy Solis initiated the bullpen’s scoreless effort with a spotless inning in his first outing since Aug. 15. Shawn Kelley was assigned the eighth inning, and Mark Melancon sealed the Nationals’ 92nd win with a perfect ninth for his 44th save. The triumph ensured the Nationals (92-65) would at least keep a one-game lead on the Dodgers for home-field advantage in the NLDS. The Dodgers were scheduled to face the San Diego Padres later Tuesday night.

“That’s what we’re playing for,” Scherzer said. “I know the 19 wins, yada, yada yada, but the most important thing is the team wins. Would love to have Game 5 here at Nationals Park facing the Dodgers. In a short series, home-field advantage matters.”

The Diamondbacks (65-92) jumped on fastballs to launch lasers around the ballpark off Scherzer over the first three innings, including a home run from Jean Segura on the first pitch of the game, but squandered most scoring opportunities. Five hits and a walk generated just two runs. Four runners were left on base.

Scherzer then morphed into the familiar masterful ace who is in the middle of the Cy Young award conversation. After Welington Castillo’s one-out RBI double in the third inning, Scherzer, adjusting to Arizona’s aggressiveness, retired 10 of the next 11 Arizona batters by mixing in more off-speed pitches. Seven outs came via strikeouts. The only batter to reach base was Paul Goldschmidt, with a two-out walk in the fifth. Goldschmidt was left stranded when Castillo struck out.

The Diamondbacks didn’t record another hit until there were two outs in the sixth inning, when Chris Owings’s line drive bounced off Rendon’s glove at third for an infield single. Owings took second base on Scherzer’s balk, giving Arizona its first runner in scoring position since the third inning. He was left stranded there when Scherzer struck out Mitch Haniger with the 98th and final pitch of his two-sided outing. The strikeout was his 10th of the night — giving him a league-leading 13 games with at least 10 strikeouts — and league-leading 277th strikeout of the campaign, breaking the club record and career high he set last season.

Scherzer’s turnaround kept the Nationals within two runs as the offense sputtered without a hit through five innings against Koch, a 25-year-old rookie making his first career start. Washington’s lone base runner through five innings was Jayson Werth, who reached in the first inning on a hit-by-pitch. Koch then mowed through the next 14 hitters until Lobaton lofted a single to center field to lead off the sixth and kick-start a comeback. Wilmer Difo, pinch-hitting for Scherzer, followed with a walk that ended Koch’s night.

Randall Delgado came on in relief and surrendered another walk to Trea Turner to load the bases. Delgado appeared on his way to navigating out of the jam with minimal damage after striking out Werth on three pitches and limiting Stephen Drew to a run-scoring sacrifice fly. But Rendon clobbered the second pitch he saw, a 93-mph fastball down and away, for his 19th home run of the season and 500th career hit to catapult the Nationals ahead. The crowd roared for a curtain call. Rendon obliged.

“Today was the official start of hero time,” Baker said. “You guys have been hearing me talk about it the whole year. Now, what do we have, six games, five games left? This is the official start of hero time.”

Note: Major League Baseball suspended right-hander A.J. Cole five games and fined him an undisclosed amount for intentionally throwing a pitch behind Jung Ho Kang’s head in Sunday’s win over the Pirates. Cole, Stephen Strasburg’s replacement in the rotation, is appealing the suspension. He was next scheduled to pitch Friday against the Marlins. Mat Latos, Reynaldo Lopez and Lucas Giolito are potential replacement options.