Juan Soto and Matt Adams hit back-to-back home runs in the eighth inning and the Washington Nationals snapped a five-game losing streak by rallying for a 12-10 win over the Miami Marlins on Friday night.

Soto’s three-run blast off Marlins reliever Tayron Guerrero was his eighth homer of the season and put the Nationals ahead for the first time at 11-9. Adams provided insurance with his fourth homer of the season, and 100th of his career.

Adam Eaton and Anthony Rendon drew one-out walks off Nick Anderson (1-2) before Soto’s homer.

Miami Marlins shortstop Miguel Rojas, left, throws to first base for a double play after forcing out Washington Nationals' Yan Gomes, right, on Gerardo Parra's ground ball to end the seventh inning of a baseball game, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Miami Marlins shortstop Miguel Rojas, left, throws to first base for a double play after forcing out Washington Nationals’ Yan Gomes, right, on Gerardo Parra’s ground ball to end the seventh inning of a baseball game, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)

Sean Doolittle gave up a homer to Jorge Alfaro in the ninth before earning his ninth save.

Starlin Castro’s two-out, RBI single off Kyle Barraclough (1-1) in the eighth gave Miami a 9-8 lead. But it wasn’t enough as Miami had its six-game winning streak snapped.

Brian Anderson hit a two-run homer to left field to give the Marlins a 2-0 lead in the first. It was Anderson’s fifth of the season.

Miami Marlins' Starlin Castro, left, singles in front of Washington Nationals catcher Yan Gomes in the eighth inning of a baseball game, Friday, May 24, 2019, in Washington. Curtis Granderson scored on the play. (AP Photo/Patrick Semansky)
Miami Marlins’ Starlin Castro, left, singles in front of Washington Nationals catcher Yan Gomes in the eighth inning of a baseball game, Friday, May 24, 2019, in Washington. Curtis Granderson scored on the play. (AP Photo/Patrick Semansky)

Adam Eaton cut the Nationals’ deficit in half with his fifth homer in the bottom half of the inning.

Washington tied it in the third on Anthony Rendon’s two-run homer, his 10th of the season.

Granderson’s sixth homer of the season — a solo shot into the second deck in right field — put the Marlins back on top, 5-4, in the fourth.

Washington Nationals second baseman Brian Dozier bobbles a foul pop fly that was hit by Miami Marlins' Harold Ramirez in the seventh inning of a baseball game, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Washington Nationals second baseman Brian Dozier bobbles a foul pop fly that was hit by Miami Marlins’ Harold Ramirez in the seventh inning of a baseball game, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)

Miami scored three runs in the fifth against Washington reliever Joe Ross, extending the lead to 8-4.

The Nationals entered Friday’s game with a MLB bullpen-worst 7.02 ERA.

Washington had four errors in the game, while Miami had one.

Washington Nationals' Anthony Rendon watches his two-run home run in the third inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Washington Nationals’ Anthony Rendon watches his two-run home run in the third inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)

TRAINER’S ROOM

Marlins: Placed C Chad Wallach (concussion) on the 10-day injured list (retroactive to May 22) and selected catcher Bryan Holaday from Triple-A New Orleans. . RHP Riley Ferrell (right biceps tendinitis) is scheduled to pitch two innings for New Orleans on Saturday. . RHP Julian Fernandez (recovering from Tommy John surgery) will pitch an inning in extended spring training on Saturday.

Nationals: Anibal Sanchez (left hamstring strain) threw a simulated game with 41 pitches on Friday. Nationals manager Dave Martinez said that it went well, and that Sanchez also ran afterward. Martinez wasn’t sure if Sanchez would make his next scheduled start; he might want to see him throw a rehab assignment.

Washington Nationals' Adam Eaton watches his solo home run in the first inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Washington Nationals’ Adam Eaton watches his solo home run in the first inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)

UP NEXT

Marlins: Marlins: RHP Sandy Alcantara (2-4, 4.25), coming off his first career shutout in a win against the Mets, makes his third career start against Washington. He’s 0-2 with a 10.13 ERA against the Nationals.

Nationals: LHP Patrick Corbin (4-2, 3.25 ERA) is 1-1 with a 4.62 ERA in six career starts against the Marlins.

Washington Nationals' Kyle McGowin, right, high-fives teammate Howie Kendrick after scoring on Adam Eaton's groundout in the third inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Washington Nationals’ Kyle McGowin, right, high-fives teammate Howie Kendrick after scoring on Adam Eaton’s groundout in the third inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)

___

Washington Nationals' Anthony Rendon, center, celebrates his two-run home run with teammate Howie Kendrick, right, in the fourth inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Washington Nationals’ Anthony Rendon, center, celebrates his two-run home run with teammate Howie Kendrick, right, in the fourth inning of a baseball game against the Miami Marlins, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Miami Marlins' Brian Anderson, right, greets teammate Curtis Granderson after Granderson hit a solo home run in the fourth inning of a baseball game against the Washington Nationals, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Miami Marlins’ Brian Anderson, right, greets teammate Curtis Granderson after Granderson hit a solo home run in the fourth inning of a baseball game against the Washington Nationals, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Miami Marlins' Jorge Alfaro walks out of the dugout after a baseball game against the Washington Nationals, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)
Miami Marlins’ Jorge Alfaro walks out of the dugout after a baseball game against the Washington Nationals, Friday, May 24, 2019, in Washington. (AP Photo/Patrick Semansky)