MIAMI — Otto Lopez crushed a two-run homer to left field — his 10th of the season — to cap a six-run ninth inning as the Miami Marlins rallied past the Washington Nationals and pulled within 3 1/2 games of the final National League Wild Card spot.

The comeback pulled the Marlins to 69-68 on the season, narrowing the gap behind the San Diego Padres (72-64) and Arizona Diamondbacks (73-65) for the last playoff berth. San Diego is playing at Tampa Bay on Sunday, while Arizona is idle.

The decisive ninth inning began with Esteury Ruiz reaching on a bunt single. Two walks and a hit batter loaded the bases before Joe Mack lofted a sacrifice fly to tie the game. Miami then took the lead when center fielder Andrew Pinckney’s throw sailed into the Marlins’ dugout, allowing the go-ahead run to score.

Jakob Marsee swiped home on a double steal before Lopez delivered the exclamation point with his two-run shot. The Marlins stole three bags total in the ninth inning, narrowing their gap on Washington for the MLB lead in stolen bases.

Lopez’s round-tripper was only the fourth hit of the game for Miami in the third contest of a wraparound series that began with a pair of frustrating defeats for a team trying to stay in contention. But those difficulties haven’t eroded the Marlins’ plate discipline against an uneven Nationals pitching staff — Miami drew at least five walks in all three games of the series.

Dax Fulton allowed one run in the eighth inning but earned his first MLB victory. Michael Peterson worked the ninth to close it out.

The Marlins continue their push for the NL Wild Card with the Padres’ result at Tampa Bay carrying direct implications for the standings.