MIAMI (AP) -- The celebratory shaving cream in Marcell Ozuna's ears provided a clue: This time it was the Miami Marlins with the walk-off hit.
After blowing leads and losing on the final pitch in back-to-back weekend games, the Marlins overcame an early six-run deficit Monday night, and Ozuna singled home the winning run with two outs in the ninth inning to beat the Washington Nationals 8-7.
Justin Bour helped reverse the script for Miami when he tied the game at 6 in the third with a grand slam , his 18th homer. Giancarlo Stanton also hit his 18th to make it 7-all in the seventh.
"That was a lot of fun," Bour said. "It was a great ballgame to be a part of. We were down six but never really out of it."
Miami bounced back after losing twice in Atlanta on walk-off hits by Brandon Phillips.
"Guys have pretty short memories. You move forward all the time," Marlins manager Don Mattingly said. "We've really had a lot of guys swinging the bat well, and I think it gives us confidence."
Bryce Harper hit his 18th homer for Washington. Anthony Rendon also homered before leaving in the fifth with a neck stinger he sustained diving for a grounder. His status is day to day.
"Nothing too serious," Rendon said. "Just trying to be a little cautious. A little scary; a jolt of pain. We'll see how it feels Tuesday."
Enny Romero (2-3) retired his first two batters in the ninth but walked Dee Gordon on four pitches. Gordon stole second and went to third on a sharp infield single by Stanton before Christian Yelich walked on a 3-2 pitch to load the bases.
Ozuna badly missed a 99 mph fastball to fall behind 0-2. Romero's next pitch was clocked at 96 mph, and Ozuna launched it to the warning track in left-center, triggering a celebration that included a shaving cream pie to his face .
"After swinging at a fastball at 99, I said, `OK, stay short and put the ball in play,'" Ozuna said. "That's what I did."
The bullpen failure was all too familiar for the Nationals.
"These guys have been giving up runs late," Mattingly said. "You get into that bullpen, you never know what's going to happen, but you know you have a chance to score some runs."
Washington's Tanner Roark squandered a 6-0 lead by giving up six runs in the third and failed to make it through the inning. The right-hander has an ERA of 7.94 in his past three starts.
"You get a six-run lead and give it up -- that's pathetic on my part," Roark said. "You get punched in the face and knocked down, you've got to get back up. This one hurt, but it's a long season and you've got to keep going."
A.J. Ramos (2-3), the Marlins' sixth pitcher, worked around a leadoff walk in a scoreless ninth.
Miami won for the 11th time in the past 13 home games.
Nationals center fielder Michael A. Taylor had a two-run single, threw out two runners on the bases and robbed the Marlins of a run with a running, backhand catch on the warning track.
Harper was slow to realize he had homered in the first inning. His line drive barely cleared the right-field fence and caromed back onto the field, and the slugger took a big turn before returning to first base, thinking he had settled for a long single. Only then did he realize the umpires were signaling the hit was a home run.
The homer was Harper's second against a left-hander this year. He extended his hitting streak to 12 games.
Before the game, the Marlins optioned RHP Drew Steckenrider to Triple-A New Orleans so they could reinstate starter Justin Nicolino from the disabled list. Nicolino lasted only three innings in his return from a bruised left index finger. Pitching for the first time since May 30, he allowed six runs, three earned.
Nationals: OF Jayson Werth (bruised foot) has yet to begin baseball activities, and there's no timetable for his return, manager Dusty Baker said.
Marlins: 3B Martin Prado (hamstring) and SS Adeiny Hechavarria (oblique) have had two games rained out since beginning minor league rehab assignments, delaying their return to the majors. Both are expected to play several more games before rejoining the Marlins.
Nationals LHP Gio Gonzalez (6-1, 2.89 ERA) is scheduled to start Tuesday against RHP Edinson Volquez (3-7, 3.72).