Each of the first three games of the four-game set have been decided by one run, with Miami (61-62) winning two of them to once again move within one game of .500.
Steve Cishek worked a clean ninth inning, striking out two while collecting his 31st save in 34 chances. Miami improved to 31-18 in one-run games.
The standout pitching by Alvarez, who lowered his ERA to 2.43, set the tone.
"This guy competes, and I think that's the beauty of Hendy," Miami manager Mike Redmond said. "I hope and I think this is true, he realizes how good he is this year. This guy has got great stuff. You saw that tonight."
With Arizona lefty Wade Miley striking out nine in seven innings, the Marlins needed a strong start from Alvarez, who went on the DL on Aug. 1 with right shoulder inflammation.
"He's no slouch," D-backs manager Kirk Gibson said. "He's very good. We saw him with Toronto as well. He's got a lively fastball. He's got a really good changeup that's got great movement. He knows how to pitch."
The D-backs were in a giving mood. Two of their five errors came in the seventh inning, which led to Miami claiming the lead with an unearned run.
Marcell Ozuna singled to open the inning, and he advanced to second on first baseman Mark Trumbo's missed catch error on a pickoff attempt. A groundout moved Ozuna to third, which brought Arizona's infield in for Jeff Mathis.
Mathis tapped a grounder to short, but Cliff Pennington's throw to the plate was wide and catcher Miguel Montero was unable to grab it. The error gave the Marlins the lead they were able to protect.
"Any time a team makes five errors, we were able to capitalize on it," Redmond quipped. "We're in one of those little ruts right now offensively.
"We're still winning ballgames and guys are grinding it out. Our pitchers are keeping us in the game and making big pitches. But of course, we need to get the bats going and make it a little easier on ourselves."
Making his first start since July 29, Alvarez got off to a shaky start, allowing three straight singles to open the game.
"I'm just thankful that everything went well," Alvarez said. "I was able to go out there and help my team. I was out there focusing on my work. We're in the hunt. This is an important stretch for us."
But the right-hander did receive a big defensive play after David Peralta's single to center.
Ender Inciarte, who singled to open the game, was thrown out at the plate by Ozuna in center. The D-backs did get on the board, though. They executed a double steal, and Pennington scored on Trumbo's sacrifice fly to center.
"At the beginning of the game, I was trying to figure things out," Alvarez said. "I wasn't myself at the beginning. I found myself out of the normal zone I'm usually in. Luckily, inning by inning, I was able to get into the rhythm of the game."
Ozuna's eighth assist of the season prevented a big first inning. The tag applied by Mathis was reviewed to see if the Miami catcher provided Inciarte with a lane. After a one-minute, 27-second review, the out was confirmed.
"I knew I was in front of the plate," Mathis said. "I knew it was going to take me across the baseline. That's when I backed up, to get myself a better hop. Ozuna made a great throw."
Miley allowed one hit through three innings, and in the second, he worked around three errors and struck out three in the inning to keep the Marlins from pulling even.
But in the fourth inning, Miami scored on Giancarlo Stanton's infield single and Jeff Baker's RBI triple.
Alvarez did receive a scare in the fourth inning when Trumbo's comeback liner struck the pitcher's left wrist. The ball was coming back near Alvarez's head, but the pitcher got his hands up and avoided a potentially serious situation.
"Fortunately, it got him in a spot where he could still go out there to pitch," Redmond said.