Matt Wieters gets his first Gatorade bath as a National after a walk-off single in the bottom of the ninth. (Matt Hazlett/Getty Images)

As the District’s other professional sports teams languished Wednesday night, their seasons ending or perilously close, the Washington Nationals played their geographic rival, with nothing more on the line than bragging rights and a losing streak, neither of which were likely to determine their campaign.

But as one of the most eventful nights in D.C. sports history quickly morphed into one of its most depressing, the Nationals charged back from a ninth-inning deficit at Nationals Park to beat the Orioles, 7-6, providing a few ounces of light on an evening heavy with disappointment.

It was as if the Nationals got the script the Capitals or Wizards needed, a stunning comeback, completed by the man who used to play for the other guys — in this case, Matt Wieters, whose two-run single ended things in the ninth, fending off a four-game losing streak against the team with the best record in the American League.

“Our guys are pretty excited,” Manager Dusty Baker said. “That was probably the best win of the year for us tonight.”

The Nationals were a relative afterthought in District, with the Capitals and Wizards fighting for their playoff lives. Perhaps the importance of those games should provide perspective that what happens in May — for better or worse — will not define them in October.

But the proximity of playoff intensity also serves as a reminder of the little things that must go right to win when it matters, the little things that have not gone right for the Nationals this week and didn’t early in Wednesday’s game. At one point, the Nationals trailed 5-1, then 6-2 in the eighth, victimized by the kind of missed opportunities and little mistakes that could hurt them when it counts.

The game started ominously, with a crack and a thud, the former the sound of Seth Smith’s bat hitting Stephen Strasburg’s fastball deep to center field, the latter the sound of Michael A. Taylor hitting the center field wall after a futile pursuit. Strasburg found himself in trouble in that first inning but escaped.

In the second, he could not escape, undone by a grazing hit-by-pitch, two soft singles and a bunt hit. The only other runs the Orioles scored came in the fifth, when Strasburg threw a slider to Mark Trumbo that hung.

“They blooped us to death, then they blasted us to death,” Baker said. The five runs Strasburg allowed were the most he has allowed this season, the product of some breaks that broke away and a slider that didn’t.

Meanwhile, the Nationals’ offense seemed one swing away from a comeback all night. When they put two men on in the second, Taylor struck out to scuttle a rally. When they put two men on in the fourth, he hit a two-out single to bring home a run. When they loaded the bases for the heart of the order in the fifth, the Nationals got just one run, in part because Ryan Zimmerman has succumbed to baseball gravity this series and was 0 for 5 Wednesday.

“I was just hoping that bases loaded nobody out wouldn’t come back to haunt us,” Baker said, “because you hope to get a crooked number when that happens, but we only got one.”

But in the eighth, Taylor hit his first home run, a two-run shot that brought the Nationals within two. In the ninth, those little things began to pay off again.

Jayson Werth led off the inning against Orioles right-hander Brad Brach, their interim closer while Zach Britton is out with an injury. Werth, who was not originally in the lineup after suffering back spasms Tuesday night, fought Brach through an 11-pitch at-bat, fouling off pitch after pitch as he so often does.

Often, that aspect of Werth’s game is masked in the statistics, though the payoff was clear Wednesday. After taking a tempting 2-2 splitter he thought would have ended the at-bat much differently had he swung, Werth took the 11th pitch of the at-bat out to right center.

“I don’t know,” Werth said when he was asked for the key to at-bats like that. “On some level, as the at-bat goes on, I feel more comfortable.”

It seemed to stun Brach for the rest of the inning. Bryce Harper followed with a double. Daniel Murphy walked. After Zimmerman grounded out, Anthony Rendon singled to center. Normally aggressive third base coach Bobby Henley held Harper at third, leaving the tying run on base instead of trying to score it right then and there.

Had he made a different decision — like he did in last year’s playoffs — perhaps the rally would have stalled; Adam Jones’s throw came in on time and seemed certain to have gotten Harper. Wieters rendered the whole thing moot a few seconds later with a single through the right side.

“We just needed a win,” Wieters said. “We’d kind of played poorly the first two games all around. Finally, we were able to get some momentum there in the last inning.”

That last inning lifted the Nationals to their 22nd win, most in the National League, enough to have a firm grip on first place in the National League East. It provided a preview of what could go right and what might go wrong when things matter most in October, of how important the little things will be when the Nationals are the ones playing with their season on the line.

“Last year I was calling for a Beltway World Series,” Baker said. “That would be kind of a dream come true for all of us.”