When the Phillies awoke Monday in Washington, they had cause for optimism. Four more wins will almost certainly put them in the playoffs, and their best pitchers — Zack Wheeler and Aaron Nola — just so happened to be starting four of the final seven games.

It was all lined up to pop champagne for the first time since 2011.

And now? It’s a jumbled mess.

Wheeler gave up two runs in a 34-pitch first inning Monday night. And although he pulled it together and kept the game close for the better part of six innings, the Phillies committed three errors and mustered six hits in a 5-1 loss to the Washington Nationals that left the wild-card race tighter than a vice grip.

“We played poorly. I mean, really poorly,” said manager Joe Girardi, who got ejected in the third inning along with centerfielder Roman Quinn for arguing a called third strike. “That’s what bothers me more than anything. We gave them runs. Some days you’re not going to hit, but [Wheeler’s] starts are really important to us the way he pitches.”

The loss dropped the Phillies back to the .500 mark at 27-27 and out of the No. 7 spot in the eight-team postseason field. The Cincinnati Reds won at home, 6-3, over the Milwaukee Brewers, to leapfrog the Phillies, leaving them to wait for the West Coast results to determine if they would fall behind the San Francisco Giants, too, and out of the playoff picture.

It was a frustrating night all around. Girardi quarreled with home-plate umpire Junior Valentine’s strike zone and didn’t like that Valentine ejected Quinn after he turned to walk back to the dugout. The Phillies thought Jean Segura was safe on an attempted steal of second base in the second inning.

Bryce Harper returned to the lineup after pulling himself out of Sunday’s game in the seventh inning with lower-back stiffness. But he went 0-for-4 with three strikeouts, one of which came on a dirt-diving splitter from Nationals starter Anibal Sanchez with the tying run in scoring position in the fifth inning.

Harper said his back has nagged him for a while. It acts up more when he’s standing in the outfield or when he begins to uncoil to swing and has to stop. But he also wasn’t about to use his injury as an excuse for the considerable drop-off in his production since the season’s first month.

“I think the biggest thing for my swing right now is I’m swinging at balls out of the zone and not hitting the ones in the zone,” Harper said. “I’m not going to blame it on my back or anything like that. If I can square a baseball up, then I can square a baseball up.”

The Phillies have lost back-to-back starts made by Wheeler, who became the first pitcher in franchise history to allow three runs or less in each of his first 10 starts with the team, according to the Elias Sports Bureau. He’s slated to pitch the penultimate game of the season on Saturday at Tampa Bay, with Nola lined up to start the first game of Tuesday’s doubleheader and the season finale Sunday.

In an ideal world, the Phillies hoped to clinch a playoff spot before Sunday and save Nola for Game 1 of the best-of-three wild-card playoff series. Instead, the race likely will go right down to the wire.

Wheeler threw a season-high 113 pitches in only 5⅔ innings. He gave up one first-inning run on an RBI single by Asdrubal Cabrera and another when catcher Andrew Knapp’s throw on Brock Holt’s steal of second base skipped into center field.

Otherwise, Wheeler overcame control difficulties — an improvement that he credited to a between-innings adjustment of his mechanics — to give the Phillies a chance, at least until reliever Blake Parker gave up two runs in the seventh inning.

The Phillies went 0-for-4 with runners in scoring position. They left eight men on base. And they scored their run on a balk, of all things, by Sanchez with two out in the fifth inning.

Wheeler, meanwhile, had retired nine consecutive batters and 13 of 15 when he went back out for the bottom of the sixth. But he gave up back-to-back singles to Cabrera and Holt and Luis Garcia’s one-out tapper in front of the mound that drove home Cabrera to stretch the margin to 3-1.

The Nationals effectively put the game away in the seventh. Holt stroked an RBI single the other way to left field, where Mickey Moniak’s throw sailed past third base, skipped out of play, and enabled Cabrera to score.

“We need to win these games down the stretch. Every game counts,” Wheeler said. “I wish tonight was a different outcome. I wish I could’ve started us off on a better foot. But we’ve got Aaron out there tomorrow, and hopefully we can start reeling off some games here.”