SAN DIEGO — A sunny afternoon was quiet, a dragging game was still tied, and the Washington Nationals’ offense was on the verge of wasting a dominant start by Stephen Strasburg until . . .

Boom. And boom. And boom. And another big, loud boom.

That was the Nationals slugging back-to-back-to-back-to-back home runs in the eighth inning, breathing life into their lethargic bats and burying the San Diego Padres in a 5-2 win Sunday at Petco Park. The four consecutive homers — the ninth time that has happened in major league history — were smacked by pinch hitter Howie Kendrick, Trea Turner, Adam Eaton and Anthony Rendon, all coming against former Nationals reliever Craig Stammen. And they made a winner out of Strasburg, who turned in another strong start by tossing seven innings and giving up one run.

Kendrick got it started with a 421-foot liner that crashed into the digital scoreboard beyond the left field wall. Turner followed with a 425-foot shot to center. Eaton’s 402-foot moonshot just got over the fence in right-center. And Rendon’s traveled just 391 feet to right, raising the question of whether it should have counted at all.

“So I went and looked at the exit velocities, and he hit his the softest — I have no idea how it went out,” Turner said of Rendon’s blast as the third baseman yelled “Play the wind!” from one locker over. “He’s got it going for him right now.”

They totaled 1,639 feet in just four minutes and turned a 1-1 tie into a 5-1 lead. They squeezed the damage into seven pitches, taking advantage of a curveball followed by three sinkers that caught way too much of the plate. It was the second time in club history that the Nationals hit four consecutive homers, with the previous bunch coming July 27, 2017.

No one had done it since, and the Nationals are the only team in MLB history to do it twice. This is how those involved saw history unfold:

Kendrick: “He just happened to make a mistake, and I haven’t had much success against Stammen at all. So right there I was just happy to get the barrel on the ball.”

Turner: “I got a fastball over the plate and put a good swing on it.”

Eaton: “If you said four home runs, I would never be in that mix — anywhere. The first one. The last one. In the middle. I was happy that I was in there.”

Rendon on whether the pressure was lifted once the Nationals had built a lead: “No, not really, because you don’t want to be the one that doesn’t hit a homer.”

By splitting the series, taking the last two games to do so, the Nationals have not dropped one since they were swept by the New York Mets in a four-game set that concluded May 23. Since that fourth loss to the Mets, the Nationals (30-35) are 11-4 and hanging within seven games of the first-place Philadelphia Phillies in the National League East. This was always going to be a softer part of the schedule, but a disastrous start added pressure to it. And still, to this point, the Nationals have taken close to full advantage.

The Padres rolled out a stream of relievers instead of using a traditional starting pitcher. That would seem to make it hard for a manager to craft a lineup, but the Nationals’ Dave Martinez wasn’t too fazed. He felt comfortable facing the relievers in the last game of the series, rather than the first or second, because his team had already spent three days facing San Diego’s bullpen. It may have taken a bit, but the offense eventually followed that logic.

“You’re getting a fresh pitcher every time, but they have to throw nine innings of relief,” he said. “Eventually, for me, that’s going to catch up with them if we keep putting pressure on them and working counts.”

Luis Perdomo got through 3⅓ innings before he was hooked, giving up an unearned run in the first after Ian Kinsler dropped a routine pop-up. Next came Robbie Erlin, who lasted 1⅔ innings and did not give up a run. Trey Wingenter threw a career-high two innings and mowed through the Nationals. Then Stammen entered and couldn’t stop giving up home runs.

Strasburg, on the other hand, knifed through the Padres by living in the strike zone. He threw 22 of 27 pitches for strikes in his first trip through the order. He worked in and out of jams, only giving up a run in the fourth, and navigated around a few mistakes behind him. And when his outing was finished, with the score still knotted, Strasburg had thrown 104 pitches and delivered an opportunity to the offense.

“You just try to keep the score as close as possible for the chance of that happening,” he said. “And it did today.”

The outburst came in the half inning after Strasburg exited, so he was able to hang on it with everyone else. Kendrick’s solo homer was his 11th of the season, and he is only seven from the career high he set in 2011. Turner’s was a good sign as he continues to get right after breaking his right index finger in April. Eaton, who hit just five homers last season, has six this year and three since May 22. And Rendon, the anchor of Washington’s surging lineup, had Strasburg jumping up and down, arms raised, face filled with a smile as his teammates danced around him in a cramped dugout.

Bundled together, once Stammen left to boos and the Nationals’ celebration cooled, those four swings offered them history and yet another win. They were thrilled to be a part of both.

“I don’t think I’ve ever seen that,” Martinez said before deciding that, no, he definitely hadn’t. “I liked the first one, for sure; that put us ahead. And then it was wow . . . wow . . . and wow.”

More on the Nationals: