MIAMI — Pavin Smith hit a two-run homer in the ninth inning, and the Arizona Diamondbacks beat the Miami Marlins 8-7 on Wednesday after left-hander Madison Bumgarner was ejected.

Bumgarner gave up a leadoff homer to Jon Berti in the first, and then retired the next three batters. As he was walking to the dugout, the pitcher gestured with his arm before holding his hand out for a foreign-substance check by first base umpire Dan Bellino.

Bumgarner said something to Bellino as the check was ending, and the umpire threw him out. Bumgarner then started yelling at Bellino and had to be restrained by some coaches.

"You guys have seen the video," Bumgarner said. "I don't know if I could say anything that would make the situation better. What I am going to say is I'm extremely proud of our team, coming back. Obviously, I didn't go into the game with the intention of throwing one inning. Everyone picked me up today."

Bellino told a pool reporter that Bumgarner was ejected for directing profanity at an umpire. Video of the foreign-substance check showed Bellino staring at Bumgarner while he repeatedly patted his hand, but Bellino said he didn't think that was a factor in the ejection.

"I wouldn't say he took exception to it. It was just a hand check," Bellino said.

It was Bumgarner's second career ejection. He also was thrown out on June 11, 2018, for arguing balls and strikes.

The Marlins scored two runs in the seventh and eighth to take a 7-6 lead. But the Diamondbacks rallied in the ninth, completing a three-game series sweep.

Daulton Varsho hit a one-out single against Anthony Bender (0-3) before Smith connected for his third homer of the season.

"Bender put one down the middle," Smith said. "I made an adjustment when I saw the spin just trust myself and swing instead of waiting too long."

Smith, of neighboring West Palm Beach, homered twice in the series to the delight of family and friends in the stands.

"My family was on the third row, coming around third I saw them going crazy, phones out," Smith said. "I just pointed to them. It's always great to perform in front of your family because I wouldn't be here without them."

Ian Kennedy got three outs for his third save.

"I am so proud of these guys," Arizona manager Torey Lovullo said. "I think we were very emotional there in the very beginning. It was a great team win."

Jesús Aguilar had three hits for Miami, which dropped its fourth straight game. Berti and Bryan De La Cruz each drove in two runs.

De La Cruz's RBI single tied it at 6 in the eighth. The Marlins then went in front when Jazz Chisholm Jr. scored on a wild pitch by Keynan Middleton (1-1).

"These hurt," Miami manager Don Mattingly said. "Anytime you lose late like that it hurts you. We finally get that big hit that we needed to break through and you feel like OK we have a chance to put a game away and we're unable to do it."

Varsho's two-run homer capped a five-run fourth against Miami starter Elieser Hernández, erasing a 3-0 deficit. Sergio Alcántara hit a two-run triple and Geraldo Perdomo had an RBI single.

Hernández was lifted after four innings. The right-hander allowed five runs and five hits.

Arizona stretched its lead in the sixth. Ketel Marte raced home on Sergio Alcántara's single and an error on De La Cruz in center.

DRIVERS MAKE THEIR PITCHES

Formula 1 car racing drivers Max Verstappen and Sergio Pérez threw out ceremonial first pitches before the game. Verstappen and Pérez will participate in the inaugural Miami F1 Grand Prix on Sunday at Hard Rock Stadium in Miami Gardens.

TRAINER'S ROOM

Marlins: RHP Sixto Sánchez (right shoulder surgery) increased his throwing program to 60 feet.

UP NEXT

Diamondbacks: RHP Merrill Kelly (2-1, 1.27 ERA) is scheduled to start the opener of a three-game set against Colorado on Friday.

Marlins: LHP Jesús Luzardo (2-1, 3.10 ERA) will start the opener of a four-game series at San Diego on Thursday.

___

More AP MLB: https://apnews.com/hub/mlb and https://twitter.com/AP_Sports