Bryce Harper had the first multi-homer game of his career -- hitting two -- and the Washington Nationals snapped a five-game losing streak Wednesday with an 8-4 win over the Miami Marlins.

Harper had a two-run homer and a solo blast before he was ejected in the ninth inning for slamming his helmet to the ground after hitting into a double play.

The Nationals, shut out 9-0 in the opener of the two-game series Tuesday, had 13 hits. The NL East leaders avoided what would have been a season-high sixth straight loss.

"A little something for everybody in that one," said Nationals manager Davey Johnson. "A great win. Makes the trip home easier."

Kurt Suzuki also homered and Ross Detwiler (8-6) got the win after allowing three runs on four hits and a walk in 5 2/3 innings. Detwiler struck out four.

Jacob Turner (0-2) gave up five runs on six hits in five innings to take the loss, striking out six without a walk.

"I made mistakes and they capitalized them," Turner said. "I have to be more consistent."

Donovan Solano went 3-for-4 for Miami.

The Marlins had runners at second and third with no outs in the eighth inning but Drew Storen came in to retire three straight and Tyler Clippard threw a 1-2-3 ninth to finish the game.

The Nationals were scoreless in their last 14 innings before Harper's first homer of the game made it 2-0 in the fourth. Jayson Werth had reached on a leadoff single, Washington's first hit of the game, and scored on the blast.

Michael Morse's triple and Ian Desmond's single knocked in two more runs in the inning for a 4-0 lead and Harper hit an upper-deck homer to right in the fifth to make it 5-0.

Solano's one-out double in the first inning, which Harper couldn't handle in center, was Miami's only hit until Giancarlo Stanton doubled to lead off the fifth. Stanton scored after back-to-back fly outs by Justin Ruggiano and John Buck.

The Marlins scored two runs in the sixth to chase Detwiler from the game. Bryan Petersen drew a leadoff walk, went to second on Solano's single and scored on Jose Reyes' base hit. Solano came home on Carlos Lee's ground out, bringing in Ryan Mattheus to replace Detwiler.

They tacked on another run in the seventh, but could have had more. Singles by Ruggiano and Buck and a sac bunt from Donnie Murphy had runners on second and third and pinch-hitter Greg Dobbs made it a one-run game with a sac fly.

Mattheus got Gorkys Hernandez on a line drive to end the threat and the Nats pushed their lead to 6-4 in the eighth after Ryan Zimmerman doubled and came home on Morse's single.

Solano singled and Reyes doubled off Sean Burnett to start the bottom of the inning. But Storen got Lee on a fly out, then struck out Stanton swinging and retired Ruggiano on a grounder to get the Nationals out of it.

Suzuki hit his first homer as a National leading off the ninth against Heath Bell and Werth added an RBI single.

Harper was ejected by first base umpire C.B. Bucknor, who then had a heated exchange with Johnson on the field. The Nats manager had cooled by the time he spoke with reporters, calling Harper "a 100-percenter" but saying the rookie needed to avoid such displays.

"He's young. He'll learn," said Johnson.

Game Notes

The Nationals went 1-4 on a five-game road trip that started with a sweep in Philadelphia. They will begin an 11-game homestand on Thursday against the Cardinals ... The Marlins continue a nine-game homestand Friday against the Mets.