PHOENIX — The Arizona Diamondbacks completed an improbable run to their first NL West crown in four years, beating San Francisco 3-1 Friday night when rookie Paul Goldschmidt lined a two-run triple off Sergio Romo in the eighth inning.

PHOENIX — The Arizona Diamondbacks completed an improbable run to their first NL West crown in four years, beating San Francisco 3-1 Friday night when rookie Paul Goldschmidt lined a two-run triple off Sergio Romo in the eighth inning.

Manager Kirk Gibson's team completed its worst-to-first turnaround in raucous fashion, rallying to beat the Giants with Chase Field buzzing as it rarely did over the past couple of seasons.

A year after going 65-97, Arizona is 91-66 in its first full season under Gibson and heading to the playoffs.

"I don't care if it's your first year or your 10th year, it's what you set out to do," Gibson said.

Ryan Roberts got the go-ahead burst started with a double off Matt Cain (12-11) and Goldschmidt finished it off with his first career triple to the corner in right.

David Hernandez (5-3) struck out two after allowing a one-out single in the eighth and J.J. Putz recorded his 44th save.

The loss dropped the defending World Series champion Giants five games behind Atlanta for the NL wild-card spot. Orlando Cabrera hit his first homer 124 at-bats for San Francisco, which has just five games left.

"We are breathing. Five games left, we are still breathing," Giants manager Bruce Bochy said. "That is why there is no need to talk. We've still got baseball."

Arizona went through a magnificent May, closing the month 15-3 to take the NL West lead and stayed near the top through July. The Diamondbacks seized control of the division at the end of August into September, going up by as much as 91/2; games before San Francisco came back with an eight-game winning streak.

But after winning three of four to start this week, Arizona found itself on the cusp of its first NL West title since 2007, needing to beat the Giants just once in the weekend series to pop the corks.