The Nationals loaded the bases in the ninth against Seth Maness (0-1) when Danny Espinosa singled with one out for his third hit, Jose Lobaton singled through the right side of the infield and pinch hitter Nate McLouth walked.
In his second game since being activated from the seven-day disabled list following a concussion, Span lofted a fly to left field. Espinosa easily beat the throw from Jon Jay, who shifted over from right field as St. Louis used a five-man infield.
Harper started in left field and went 1 for 4. The two-time All-Star was pulled from the game a day earlier for what manager Matt Williams called a "lack of hustle" after he failed to run out a comebacker to the mound.
Span grounded out with the bases full in the sixth before delivering the game-winner.
The Nationals split the four-game series. They had lost eight of the previous nine meetings with the Cardinals going into the series wrapup.
Rafael Soriano (1-0) pitched one inning for the win.
The Cardinals took an early edge against Stephen Strasburg and led 2-0 going into the seventh.
Strasburg struck out nine in six innings.
Shelby Miller left with the lead after pitching 5 1-3 innings for the Cardinals. He also hit a two-out, RBI double off Strasburg in the fourth.
St. Louis starting pitchers recorded an RBI in three of the four games versus Washington. Miller allowed four hits, striking out seven and walking five.
Matt Adams doubled twice and scored for the Cardinals.
NOTES: Cardinals OF Matt Holiday didn't play. It was a day of rest, manager Mike Matheny said. ...St. Louis will recall LHP Tyler Lyons from Triple-A Memphis to start at the New York Mets and make a corresponding roster move before Monday night's series opener. Last season he finished 2-4 with a 4.75 ERA in 12 appearances, including eight starts for the Cardinals. Lyons replaces RHP Joe Kelly (strained left hamstring), who was put on the disabled list Thursday. ... The Nationals open a three-game home series with the Los Angeles Angels on Monday night with Washington RHP Tanner Roark (1-1, 5.29) facing RHP Garrett Richards (2-0, 2.84).
Link to box score: Washington 3, St. Louis (11-8) 2
Join the pre-game, in-game and post-game discussion about each contest at The Cardinal Nation message board.