St. Louis had forged a 2-2 tie in the top of the seventh on David Descalso's two-run homer against Sean Burnett, but the Nationals responded in the next half-inning.
Michael Morse and Chad Tracy each singled with two out against Lance Lynn (13-6), with Eury Perez coming in to run for Morse. Perez stole third base and then scored the go-ahead run when Desmond sent a single up the middle.
Tracy went to second on the play and came home with what turned out to be the decisive tally on Espinoza's hit for a 4-2 Nationals lead.
Ryan Mattheus (5-1) earned the victory despite yielding a run in the eighth and Tyler Clippard notched his 29th save as National League East-leading Washington took 3-of-4 games against the Cardinals.
Kurt Suzuki went 2-for-3 with a solo homer and two RBI for the victors.
St. Louis, which held a 1 1/2-game lead for an NL wild card spot coming into Sunday, lost for the fourth time in five contests.
Boston schools pull out free condoms over wrapping complaints
NBC reportedly holds celebs hostage to Jimmy Fallon's show