The Phillies’ Andrew Knapp circles the bases after his walk-off home run in the 13th inning sent the Nationals to a 4-3 loss. (Eric Hartline/USA Today Sports)

The calendar flipped to July on Sunday, which meant the Washington Nationals’ worst month in eight years was behind them. It was a chance to start fresh after completing a 9-16 June fraught with offensive shortcomings. And the first day presented the Nationals an opportunity to salvage a series split with the Philadelphia Phillies, one of the two ascending clubs challenging them for the National League East throne.

But June’s stench lingered into Sunday as a familiar set of problems vexed the Nationals in a 4-3, 13-inning loss at a scalding Citizens Bank Park. Gio Gonzalez fizzled in the fifth inning, forcing the Nationals to turn to their bullpen early, and the offense squandered opportunities, giving the valiant relief corps little margin for error. That margin evaporated when Justin Miller surrendered a pinch-hit, walk-off home run to Andrew Knapp to snap a tie that had held since the fifth inning.

The loss dropped the Nationals (42-40) three games behind the second-place Phillies (45-37) and six games behind the first-place Atlanta Braves. It’s the latest they have been at least six games out of first place since they finished the 2015 season seven games behind the New York Mets.

The loss also completed a 1-5 trip for the Nationals. Next up: a three-game series against the Boston Red Sox, owners of baseball’s best record entering Sunday.

“There’s no panic, but when there’s a glaring issue, [whether] it be runners in scoring position or getting guys on, you got to fix it,” outfielder Adam Eaton said. “And you got to do it sooner than later.”

Miller entered the game in the 12th inning after he pitched the previous two days simply because there weren’t any other arms remaining. He was needed because the offense was incapable of producing clutch hits, leaving seven runners on base after the sixth inning. The Phillies weren’t any better until Knapp turned on Miller’s 35th pitch — and 67th since Friday — and deposited it to the seats beyond the right field wall.

“I was fine,” Miller said. “Toward the end I was getting a little gassed, but, I mean, I threw a fastball. That’s my best pitch. He put his best swing on it, and he won the battle.”

It was a battle of attrition. Each team used eight relievers. If the game had advanced any further, position players would have taken the mound for both teams. Jesmuel Valentin would have been Philadelphia’s choice. Mark Reynolds, a knuckleballer, would have given it a shot for Washington.

Before having to figure out how to navigate extra innings, Nationals Manager Dave Martinez met the new month with a couple of noteworthy changes to his lineup. He dropped Bryce Harper to fifth in the batting order for the first time this season in hopes that he would get more opportunities with runners on base. He penciled Daniel Murphy in as the starting second baseman for the first time since his microfracture knee surgery in October.

Playing center field, Harper went 0 for 4 with two walks and grounded out with two runners on base in the 10th inning. Two innings earlier, the Phillies intentionally walked him with first base open to face Murphy. It was the second time the Phillies had intentionally walked a batter in the eighth inning to get to Murphy in a week. The previous Sunday night, they gave Juan Soto a free pass, and Murphy made them pay with a two-run, go-ahead single. On Sunday, Murphy, who played the entire game, grounded out to conclude the inning.

The Nationals belted seven home runs Friday and another one Saturday, but they manufactured their way onto the board with some small ball Sunday. The process began with Trea Turner dropping a bunt to lead off the fourth inning. Phillies catcher Jorge Alfaro, boasting one of baseball’s best arms, tried getting the swift Turner at first base, but his throw sailed wide, and Turner took second base on the error.

Soto then grounded out to the right side to advance Turner to third base before Anthony Rendon lofted a flyball to right field deep enough to score Turner. An inning later, Eaton smacked a two-out, two-run single to right field to give Washington a 3-0 lead against Jake Arrieta, who was taken out after 71 pitches and five innings on the sweltering afternoon.

Meanwhile, Gonzalez did not resemble the pitcher who had allowed 17 combined runs in his previous four starts and lasted one inning in his last start. He was efficient and crisp for four innings, cruising through 49 pitches.

Then it all disintegrated. The tailspin commenced when he walked Valentin to start the fifth. Two walks and two hits later, after Odubel Herrera whacked a two-out single to right field, the score was knotted at 3. Gonzalez was flustered. He and catcher Pedro Severino appeared out of sync. Martinez let him finish the 40-pitch inning, but then his afternoon was over. It was a rapid downfall and marked the third time a Nationals starter didn’t pitch beyond the fifth inning in the four-game series.

“He fell behind that inning, and that’s what happens,” Martinez said. “When he falls behind and walks guys, bad things happen.”

Both teams had opportunities to break the deadlock before extra innings. Eaton struck out with two on in the seventh. Murphy grounded out with two on in the eighth. In the ninth, Reynolds worked a leadoff walk before Severino, who failed to get a bunt down twice, struck out, and Michael A. Taylor grounded into an inning-ending double play. In the 10th, Harper grounded out meekly with two more runners on base.

“Offensively, we’ve got to do more,” Eaton said. “That’s plain and simple. We score early and then we can’t coast. We can’t take our foot off the accelerator. We got to keep going.”

On the other side, Philadelphia left two on in the seventh inning and two more in the ninth, which concluded with Sean Doolittle inducing an inning-ending double play on his first pitch. Doolittle returned for the 10th and retired the Phillies in order on 13 pitches. Despite the low pitch count, Martinez elected to swap Doolittle with Shawn Kelley in the 11th.

Kelley worked a perfect inning but was replaced with a pinch hitter to lead off the 12th. The sequence forced the Nationals to turn to Miller. He kept the Phillies off the board for an inning but couldn’t repeat the effort, and the Nationals began July as they ended June — with a loss, wondering when they will turn it around.