MIAMI — Javier Sanoja, the 5-foot-7, 150-pound infielder who entered as a pinch-hitter in the sixth inning, delivered a bases-loaded single up the middle off Clayton Beeter in the ninth to give the Marlins a 3-2 walk-off victory over the Nationals at loanDepot park Friday night.

The hit — Sanoja’s first career walk-off — was the Marlins’ sixth walk-off win of the season and snapped a three-game losing streak to open a six-game homestand. “I’m happy. The plan was just to put the ball in play, and I’m very happy I was able to do that,” Sanoja said via Marlins interpreter Luis Dorante Jr. “I saw they’re playing in, and I was able to put the ball through the infield.”

Miami had managed just one hit through seven innings before Jakob Marsee led off the eighth with a triple down the right-field line, just beyond the outstretched glove of first baseman Abimelec Ortiz. Sanoja followed with an RBI single off Tom Cosgrove to tie the score, and Otto Lopez added an RBI single to right field to give the Marlins the lead. “Up until that point, we hadn’t really done anything,” Marlins manager Clayton McCullough said. “We had a lot of soggy at-bats, a lot of early outs, soft contact. Sometimes all it takes in a game that close is one knock to spark things, and certainly great placement by Marsee getting it into the right-field corner and using his speed to turn it into a triple. That was really the hit tonight that sparked us.”

Washington tied the game in the top of the ninth before Agustín Ramírez drew a walk to lead off the bottom half. Esteury Ruiz reached on a bunt single and advanced to second while Ramírez was safe at third on Beeter’s throwing error. Marsee was intentionally walked to load the bases for Sanoja.

The 23-year-old Sanoja carried a .379 on-base percentage, .581 slugging percentage and .960 OPS over his previous 20 games into the contest. “He’s always ready,” McCullough said. “And you forget how young Javi still is, not only from a Major League experience standpoint, but age — he’s 23, and we ask him to do a whole lot. It’s not easy on a young player [to] be ready to play a lot of different positions. … He’s just so valuable with what he can do, and he gets the ball to all fields. And you see him time and time again, when things are the hottest, he has a real ability to stay in that moment and come through.”

Sanoja credited his mental approach. “I’m not thinking much about that,” he said. “I’m mostly focused on my discipline. I think one of the most important aspects of the game right now is mental. I’m trying to respect that part of the game.”

Marlins starter Ryan Gusto went four innings, allowing five hits and no runs with two strikeouts and a walk before giving way to right-hander Josh Ekness. “Gusto was really good again,” McCullough said. “He was able to navigate around some traffic and put us in a position where we were able to do what we did tonight.”

The win moved Miami to one game back over .500 and improved its home record to 39-25, the fourth-most home wins in Major League Baseball behind the Brewers (44), Rays (43) and Braves (42). “Better late than never,” McCullough said. “This time of year, wins are wins. Probably not our greatest effort up until the eighth and ninth, but we pitched really well and gave the offense a chance to be able to hang in there and just do enough to win.” The Marlins have now beaten Washington six consecutive times this season and continue the homestand with five games remaining at loanDepot park.