MIAMI — The Marlins completed a series sweep of the Washington Nationals with a 6-2 victory, pulling within four games of the San Diego Padres for the final National League Wild Card spot with 31 games remaining in the regular season.

Miami, now 67-64, entered the finale with just a 5.6 percent chance at making the postseason, but a lineup that produced timely hitting throughout the afternoon gave manager Clayton McCullough’s club reason to believe the math can shift. Heriberto Hernández set the tone early with a double that scored Agustín Ramírez — who had worked an 11-pitch walk on his bobblehead day — to give Miami a 1-0 lead in the first inning.

Right-hander Janson Junk allowed one run through 4 2/3 innings before McCullough turned to reliever Michael Petersen with a pair of runners on base. Petersen loaded the bases with a walk but struck out Abimelec Ortiz on a slider to end the threat.

The Marlins broke the game open with a two-out rally in the fifth. Otto Lopez walked, Ramírez singled and Hernández walked to load the bases, setting up Xavier Edwards’ two-run single to left that pushed the lead to 3-1. After Washington trimmed the deficit to 3-2 in the sixth against righty Calvin Faucher, Miami answered immediately — Joe Mack delivered a pinch-hit RBI double and Lopez added a sacrifice fly to give the Marlins a 5-2 lead. Mack tacked on a run-scoring fielder’s choice in the eighth.

Jack Ralston, recalled from Triple-A Jacksonville as the corresponding roster move for John King, tossed a scoreless seventh and eighth innings. Closer Pete Fairbanks worked around trouble in a scoreless ninth in a non-save situation to seal the sweep.

The Padres, at 70-60, hold the final Wild Card position with both clubs facing 31 games to settle the race through the end of the regular season.