SEATTLE -- Seattle Mariners left fielder Dustin Ackley continued his breakout season with another home run, his second in as many days, and it came at a good time Sunday afternoon.

Ackley's three-run homer in the fifth inning gave Seattle its first lead since early Friday evening and turned out to be the game-winner in a 5-3 victory over the Washington Nationals on Sunday. With the victory, the Mariners (73-62) avoided the series sweep and moved to within a half-game of Detroit in the race for the second American League wild-card spot.

"Especially on a travel day like this, that was huge," Ackley said of the win.

Ackley and the Mariners overcame two home runs from Washington slugger Bryce Harper to snap a three-game losing streak. His three-run home run in the top of the fifth put Seattle on top 4-3, the Mariners' first lead since the second inning of Friday's series opener. That was enough on a night when Mariners starter Hisashi Iwakuma gave up three solo home runs, two of them to Harper, in six innings.

Seattle closer Fernando Rodney earned his 39th save of the season, the second-highest total of his career, despite giving up a leadoff single to Harper in the top of the ninth.

"It was a good win," Seattle manager Lloyd McClendon said. "You never want to be swept, particularly at home."

The Mariners beat the Nationals for the first time since 2004. Washington won the previous 11 head-to-head meetings, which was the major leagues' longest active streak.

Harper had his first multi-homer game of the season and the fifth of his career.

"It felt pretty good to get that lead early," he said. "I wish we could have won the ball game, but sometimes that doesn't happen."

Seven of Harper's 10 home runs this season have come in the month of August. He missed 57 games with a sprained thumb, and manager Matt Williams said Harper looks close to 100 percent.

"His hand is getting stronger," Williams said. "It allows him to stay back, stay calm and keep his body down a little bit. We've seen over the last couple of weeks that it's getting there. He swung a good bat (Sunday)."

Harper got the Nationals on the board in a big way with a colossal home run in the top of the second inning. The left fielder's solo shot to right went 418 feet, giving Washington a 1-0 lead.

Right fielder Nate Schierholtz followed with a leadoff shot in the third to put the Nationals ahead 2-0.

After Seattle cut its deficit to 2-1 on an RBI single from Ackley in the bottom of the third, Harper went deep again. His solo shot in the top of the fourth inning gave Washington a 3-1 lead.

After back-to-back, one-out singles by shortstop Brad Miller and center fielder Austin Jackson in the bottom of the fifth, Ackley hit a 2-0 pitch from Washington starter Tanner Roark over the right field fence for a three-run home run and a 4-3 Seattle lead.

"I was just looking for something fast and hard," Ackley said, "something to drive. I'll take it. I like going down the line rather than in the gaps; you have to hit it a long way to get it out when you hit there."

Right fielder Endy Chavez gave the Mariners an insurance run with a two-out double in the bottom of the eighth. Chavez's hit came on a 2-2 pitch, driving in pinch runner James Jones from third base after Jones stole two bases.

Iwakuma (13-6) allowed five hits and struck out six. He did not issue a walk, marking the 13th time in 23 starts this season that he did not walk a batter.

"Kuma did not have his best stuff, but he battled," McClendon said. "He kept us in it."

Roark (12-9) gave up 11 hits and four runs in 6 1/3 innings.

During the series, the Nationals (77-58) hit 10 home runs. Seven of them came against Seattle's top two starters -- Felix Hernandez and Iwakuma -- but six were solo shots.

With Sunday's win, the Mariners closed within a half-game of Detroit in the race for the American League's second wild card. The Tigers lost to the Chicago White Sox 6-2 Sunday.

Seattle was playing with McClendon in the dugout for the first time in the three-game series. McClendon missed games Friday and Saturday while attending a daughter's wedding in the Midwest. He arrived at Safeco Field about 90 minutes before Sunday's first pitch.

McClendon said it was difficult to track the Mariners' back-to-back losses in the series from afar.

"I was dancing with my daughter with one hand and looking at the score with the other," he said. "It was excruciating."