The Pirates were shut down after having scored 22 runs in their previous four games.
Alvarez (1-1) was called up earlier this month and this was his fifth start. He allowed only two hits and struck out five in six innings.
Steve Cishek came on to protect the two-run lead in the ninth and promptly struck out the first two batters. He then gave up consecutive singles that put runners on first and third before getting pinch-hitter Jose Tabata on a ground out. Cishek recorded his 21st save.
Placido Polanco drove in Miami's first run with an infield single in the sixth and Giancarlo Stanton hit a home run one inning later.
Jeff Locke (9-3) struck out nine over 6 2/3 innings in taking the loss.