Karstens (3-2) allowed five hits, struck out three and walked two. He has allowed one run in three home starts this season for a 0.43 ERA.

"I was kind of playing whiffle ball out there," Karstens said. "I just think to when I was a little kid, honestly, to make them take unorthodox swings -- really bad swings. That's all I'm trying to do. I'm not trying to blow fastballs by people; I'm just trying to keep people off-balance, and when they do hit the ball hard, hopefully it's right at us."

Pittsburgh completed its fourth sweep of the season -- all at home -- while matching its longest winning streak since Sept. 17-22, 2010.

The Pirates (54-40) remained a half-game behind NL Central-leading Cincinnati.

Miami has lost five straight, scoring a total of seven runs during the slide.

Alvarez's fourth homer in his past six games and No. 21 for the season came off Anibal Sanchez after Casey McGehee led off the seventh with a double, making it 3-0.

"I tried to throw something different to get an out, a groundball or something like that," Sanchez said. "But that's what's happening right now."

Jared Hughes worked a perfect eighth and Joel Hanrahan retired the Marlins in order for his 28th save in 31 opportunities. Alvarez went 2 for 3 and Andrew McCutchen had two more hits to improve his major league-leading batting average to .372.

The Pirates have won 21 of their past 25 games at PNC Park to run their home record to a majors-best 32-14.

Karstens and Sanchez cruised through the middle part of the game. Sanchez retired 12 straight from the end of the second until a two-out single by McCutchen in the sixth, and Karstens sent down 15 of the next 16 he faced after a rocky first inning.

Karstens walked two and allowed two infield singles in the first, but Miami did not score. Jose Reyes was picked off first and Greg Dobbs flied out to end the inning.

Justin Ruggiano's single was erased by a double play in the fourth, and the Pirates benefited from some breaks in the seventh.

Logan Morrison led off with a single and stole second. Dobbs' sinking liner to left-center with one out was initially ruled a diving catch by Alex Presley. But the umpires conferred after Miami manager Ozzie Guillen came onto the field to argue, and they ultimately awarded Dobbs a single.

But Morrison remained at second base, thinking he needed to tag. The Marlins pleaded their case to no avail, and Omar Infante grounded into a double play on the next pitch to end the inning.

Sanchez (5-7) allowed three earned runs in his previous two starts, shaking off a McCutchen RBI single in the first.

"Today we got great pitching from Sanchez, very good pitching," Guillen said. "Maybe just one bad pitch."

The Marlins have one RBI hit with a runner in scoring position during their losing streak. Miami (44-51) is a season-worst seven games under .500.

Inching closer to breaking a North American professional sports record of 19 consecutive losing seasons, the Pirates won for the 16th time in their past 21 games.

The near-capacity crowd of 34,203 followed sellouts on Friday and Saturday at PNC Park, which has hosted only one team that has had a winning home record.

The Pirates have won 24 of their past 30 home games.

"A lot of these guys weren't here when I was here in ['09] and we lost 99 games... and then the next year, (105), and to come out here and see the crowds that we're getting, it definitely means a lot to me and this clubhouse and the guys," Karstens said. "I think we're showing it the way we're playing. We love it, we're battling and playing hard for the city of Pittsburgh."

Notes

Fourteen of Alvarez's 21 home runs this season have come during his 29 day games.

Miami 3B Hanley Ramirez did not start for the third consecutive game while he recovers from an infection resulting from a cut on his right hand. His hand remained heavily wrapped in the clubhouse prior to Sunday's game. After the game, Guillen expressed doubt Ramirez could play Monday.

The Marlins return home to face the Braves on Monday, the start of a stretch of seven games over 11 days against them.

Pittsburgh continues its homestand against the Chicago Cubs on Monday. The Pirates' next 10 games are against the Cubs or Houston Astros -- teams that had two of the three worst records in the majors entering Sunday. Monday also begins a stretch of 13 straight games against NL Central teams.

Copyright 2015 by STATS LLC and The Associated Press. Any commercial use or
distribution without the express written consent of STATS LLC and The
Associated Press is strictly prohibited.