Danny Espinosa watches his game-winning homer in the bottom of the 10th inning. (Ann Heisenfelt/Associated Press)

The calendar has flipped past the midpoint of June, and the Washington Nationals will wake up Friday morning somewhere other than last place. For most franchises, that would mean nothing, really. That last happened for the Nationals on the final day of the 2007 season.

They might also wake up sore, from the thrashing pigpile they created around Danny Espinosa at home plate, in the 10th inning, to cap Thursday night’s 7-4, walk-off victory over the St. Louis Cardinals. Before a crowd of 19,622, after nearly losing their grip in the ninth, the Nationals clung to their current title as one of baseball’s hottest teams by winning their sixth straight game, which cinched a sweep of the Cardinals.

The best indicator about the way the Nationals feel about themselves happened shortly after the mob dispersed. As Espinosa gave a television interview in front of the Nationals’ dugout, Roger Bernadina and Ian Desmond sneaked behind and doused him with a bucket of Gatorade. Even after Desmond pushed Espinosa, he still did not know the identity of the culprits.

“It was just so fun to win that game,” Espinosa said. “To stay on a roll, to stay hot, it’s so awesome. . . . We’re turning things around. Losing isn’t acceptable in this clubhouse.”

The Cardinals came into Nationals Park on Tuesday tied for the second-best record in the National League, and they left having been swept by a combined score of 25-10. You could not be blamed for wanting to peek at the standings, and if you did, you would see the Nationals are 5½ games out of the wild-card lead.

The standings check may be premature, but in Washington it’s hard to know when it’s appropriate. The Nationals haven’t been this close to a playoff race, this late in the season, since 2005. Laynce Nix, who hit a solo homer Thursday night, played on two playoff teams before signing with the Nats this winter.

“It kind of feels the early stages of those teams, where we’ve got to convince ourselves and believe that we’re capable of that,” Nix said. “And we are. If we keep playing well and beating good teams, we’ll start realizing we can compete and should be winning those games.”

The bottom of the 10th began when Ryan Zimmerman strode to the plate, the crowd roaring and hoping they would soon be leaving. Zimmerman could not provide that with one swing, but started a rally with a groundball single up the middle.

“They’ve battled and scrapped, and I’ve been watching them,” Zimmerman said. “It’s fun to be a part of it.”

Said starter John Lannan of Zimmerman, “He just brings something to the team that you really can’t describe.”

With one out, Fernando Salas hit Michael Morse with a pitch, putting the winning run in scoring position. Up came Espinosa, who has put himself in contention for both the all-star team and the rookie of the year award.

Espinosa took a strike and two balls, then, batting left-handed, roped a high change-up from Salas toward the Nationals’ bullpen. Espinosa did not know if he had gotten every bit of it, or if he had hit it high enough.

But the Nationals had already hit three homers, and lately, “the ball is flying,” Manager Jim Riggleman said. The ball landed over the wall, and Espinosa raced around the bases and into his waiting teammates. “It went kind of quick,” he said.

In the eighth and ninth, Tyler Clippard and Drew Storen, typically the Nationals’ most untouchable relievers, made the heroics necessary by each allowing a solo home run. Clippard gave up a rocket to Albert Pujols with two outs in the eighth. Storen, trying for his 17th save in 18 chances, took over a 4-3 game in the ninth and surrendered a leadoff homer to Yadier Molina.

Sean Burnett, whose recent struggles had seemingly caused within him a crisis of confidence, made the heroics possible. He came on for the 10th to face Colby Rasmus, Pujols and Matt Holliday. Rasmus grounded out, and Riggleman could have intentionally walked Pujols. But Burnett pitched to him, and Pujols flied out to right. Burnett walked Holliday with two outs, then struck out Lance Berkman, who has hit 17 homers, looking at a 92-mph fastball on the outside corner.

“I just stopped thinking,” Burnett said. “I’ve been thinking so much out there. Things have been going so bad. I figured, ‘Just go out there and throw it.’ ”

The way the Nationals began the game, it seemed a 10th inning wouldn’t be necessary. Jayson Werth and Bernadina led off with consecutive home runs off Kyle Lohse, who in April pitched a two-hit shutout against the Nationals. Before the seventh inning Wednesday night, the Nationals had not hit back-to-back homers all season. After Bernadina’s blast, they had done it twice in three innings, and five of the last 11 Nationals hitters had smacked a home run.

Lannan preserved the lead for seven efficient innings, allowing two runs on six hits and two walks while throwing only 86 pitches. By his recent standards, it was nothing special — in his last five starts, Lannan has a 1.08 ERA in 331 / 3 innings. In 13 of the past 16 games, Nationals starters have allowed two or fewer earned runs.

Espinosa provided one small blemish when he made a throwing error in the ninth, snapping the Nationals’ franchise-record errorless streak at 1302 / 3 innings. It was a minor quibble. Lannan could not remember a winning streak this long; the last time it happened was the final game of 2009.

“I’ve been saying all year we have a really good team,” Werth said. “We kind of got on a roll here.”