The Washington Nationals played 158 games for the opportunity they arrived at Sunday morning. The baseball season is a complex, twisted endeavor, and the Nationals had reduced it to uncomplicated anticipation. Their magic number stood at one. Win, and clinch. “This is what you show up at February in spring training for,” Manager Davey Johnson said.

All of that fizzled in a matter of face-palming moments as the Nationals fell, 10-4, to the St. Louis Cardinals, a defeat that will bring the National League East race to Washington on Monday with a still-beating pulse. Ross Detwiler’s 21 / 3-inning clunker and the second-place Atlanta Braves’ 6-2 victory over the New York Mets held the Nationals’ magic number at one, building the anticipation for at least one more day.

The Nationals hoped for a happy flight home. They will instead settle for a chance to clinch first place in front of their home crowd at Nationals Park during a three-game, season-ending series against the Philadelphia Phillies. They will give the ball Monday night to John Lannan, the longest-tenured Nationals starter, the left-hander relegated this year to Class AAA Syracuse.

“This was for all the fans back in D.C.,” Detwiler said, ending a mostly glum session with reporters with gallows humor. “I wanted them to see the team clinch.”

The delay happened because of an ugly afternoon. Detwiler became the second Nationals starter in the series to melt down against the Cardinals, a possible first-round playoff foe. Chien-Ming Wang announced his arrival from the bullpen with consecutive, crucial wild pitches. Johnson let the Nationals’ best chance to come back end with Wang at the plate.

Detwiler, pitching close to his suburban home town of Wentzville, Mo., allowed seven runs in 21 / 3 innings. Only three were earned, but Detwiler shouldered most of the blame. He walked five of the 16 batters he faced, allowed four hits and used 81 pitches to record seven outs.

Detwiler said neither pitching at home nor trying for the clinch affected him. “I thought it would, but it really didn’t,” he said. His problem was an inconsistent arm slot. He dropped his elbow in the middle of his delivery, which robbed his sinker of movement and cost him precision.

“I was either spiking it or throwing it to the other batter’s box,” Detwiler said. “I think it’s trying to do too much.”

Detwiler’s downfall began in the second inning. He walked the first two hitters, giving him three walks out of the first six Cardinals batters. In a jam, Detwiler threw the perfect pitch at the perfect time: Daniel Descalso chopped a 93-mph sinker to second base, a room-service double-play ball.

And then Danny Espinosa booted it. He got a perfect hop, but the ball smacked off his glove and trickled away. Rather than two outs and one on, Detwiler faced bases loaded and no outs.

“I kind of handcuffed myself on a ball that I make 999 times out of 1,000,” Espinosa said. “I wasn’t able to come through right there.”

Then Pete Kozma, who tormented the Nationals all weekend, delivered another blow. His double into right field scored two runs, even though Espinosa’s bullet relay throw cut down one runner at the plate. Jon Jay’s two-out single and Carlos Beltran’s homer, his first of two, completed the damage.

After Detwiler, trailing 5-0, allowed another walk followed by a single with one out in the third, Johnson had seen enough. He summoned Wang from the bullpen to limit the damage. He only exacerbated it in the most hapless way.

Wang’s first pitched only traveled about 45 feet, a wild pitch that moved the runners to second and third. His second pitch made it closer to the plate, but just barely, and it skidded in the dirt past catcher Kurt Suzuki. David Freese raced home and Descalso moved to third, enabling him to score on Kozma’s sacrifice fly.

“I was thinking, ‘Try to get the ball down,’ ” Wang said. “It was too low two times.”

The wild pitches became more costly in the top of the fourth, when the Nationals’ offense came alive against Cardinals starter Lance Lynn. Bryce Harper mashed his 22nd homer of the season, putting him two behind Tony Conigliaro’s all-time single-season record for a teenager.

Adam LaRoche singled, then scored on Ian Desmond’s double, his 60th extra-base hit of the season. Espinosa helped redeem his error by launching a 430-foot blast over the right field fence. Suddenly, the Nationals trailed only 7-4 with more than five innings still to play.

“Three is very reachable,” Espinosa said. “Everyone was ready to go, definitely energized.”

As Suzuki, the No. 8 hitter, stepped into the batter’s box with two outs, the Nationals’ bullpen remained inactive. When Lynn hit Suzuki with a pitch, the tying run walked into the on-deck circle. But Johnson still let Wang, helpless with lumber in his hands, walk to the plate.

“I was hoping to get a little more out of him to save my ’pen,” Johnson said. “I don’t try to put my best foot forward when we’re down.”

Wang struck out to end the last qualified threat the Nationals managed. The payoff for sacrificing the inning was null. Wang walked the first hitter he faced in the fourth, then gave up another two-run homer to Beltran. The Nationals trailed, 9-4, and they would not make a game of it.

The loss dropped the Nationals to 96-63, into a tie with the Cincinnati Reds for the best record in the National League. They hold the tiebreaker by virtue of winning the season series, five games to two.

In the clubhouse afterward, they packed for home and a restful flight. They would fall asleep Sunday night still in control of their fate and wake up in October, one win from history, knowing Monday carried another game and a silver lining after a rotten day.

“Better to clinch it at home,” Johnson said.