MIAMI — Jorge Soler hit a two-run drive for his 35th homer, and the Miami Marlins beat the Washington Nationals 2-1 on Sunday to avoid a series sweep.

Luis Arraez reached on a leadoff single in the third inning before Soler connected against Trevor Williams, giving Miami a 2-1 lead. It was Soler’s 19th go-ahead homer of the season, extending his major league lead.

“Soli has been winning game after game for us, and he won another game for us today,” Marlins manager Skip Schumaker said.

Jacob Stallings had two hits for the Marlins, who had dropped six of seven to fall back to .500.

The Baltimore Banner thanks its sponsors. Become one.

“A good win for us that we needed badly,” Arraez said. “It’s been a tough second half for us. Everybody wants to win. We just need to continue playing hard.”

Washington wasted a strong performance by Williams (6-8), who allowed five hits and walked two in a season-high seven innings. The Nationals had won five of six and 11 of 14.

“The offense just couldn’t score any runs,” Nationals manager Dave Martinez said. “We had a couple of opportunities and couldn’t capitalize on them. That’s how it goes.”

Washington threatened in the ninth against Tanner Scott. Keibert Ruiz and Ildemaro Vargas hit one-out singles, but Scott retired Jacob Young on a double play grounder for his third save in five opportunities.

Scott replaced David Robertson as Miami’s closer after Robertson squandered a 2-1 lead Saturday. It was Robertson’s third blown save since the Marlins acquired the veteran reliever from the New York Mets on July 29.

The Baltimore Banner thanks its sponsors. Become one.

“We still have a lot of confidence in him,” Schumaker said. “We acquired him for a reason — to get us out of high-leverage situations, and that’s still going to happen. So I don’t want you to think because of what happened last night you won’t see him again.”

Miami reliever Bryan Hoeing (2-2) pitched four-plus innings of one-run ball for the win. Steven Okert, A.J. Puk and Andrew Nardi each pitched a hitless inning before Scott closed it out.

Hoeing departed after he was struck by Joey Meneses’ leadoff comebacker in the sixth. Hoeing limped noticeably after Meneses’ single but said later he was fine.

“He was my last batter no matter what,” Hoeing said. “When Skip came out, he said you’re coming out either way. I didn’t like to go out with a base hit.”

Washington jumped in front on Dominic Smith’s groundout in the third. CJ Abrams hit a leadoff single and advanced on Lane Thomas’ double. Smith hit a one-out dribbler to first that scored Abrams.

JT Chargois opened for Miami and got three outs before Hoeing took over.