Guerrero broke the Derby's single-round record in each of the first two rounds, but after surviving an exhausting duel with Joc Pederson of the Los Angeles Dodgers in the semifinal round, Guerrero didn't have enough to beat Alonso in the final.
The 20-year-old Blue Jays rookie, trying to follow in the footsteps of his Hall of Fame father, who won the event in San Francisco in 2007, went first in the final, and after initially struggling to duplicate his earlier pace, he picked it up after calling a second timeout and finished with 22 home runs.
Alonso, unique in the competition in sending most of his hits toward center field, then followed with 23 to end it with plenty of time to spare. He became the first Met to win the event since Darryl Strawberry was a co-champion in 1986.
"That was a blast. Oh my god, that was a blast," Alonso said after his win. "I'm gonna remember that for the rest of my life."
With the win came a cool $1 million bonus to supplement Alonso's base salary of $555,000. He said he would donate 10% of his winnings between two charities, the Wounded Warriors Project and the Stephen Siller Tunnel to Towers Foundation.
"I have the utmost respect for the people that put their lives on the line every single day -- and I just wanna show my gratitude, because a bad day for me is a lot different than a bad day for the servicemen and women that serve this country," Alonso said.
Guerrero has eight major league home runs in his rookie year, and he hit 44 total homers in the minors. But at the Derby, he hit 91.
The biggest drama of the night came in the semifinal round, when he needed three tiebreakers to eliminate Pederson 40-39.
With Guerrero going first and Pederson following, both sluggers finished with a round-record 29 home runs in the four-minute time limit, plus the 30-second bonus time for sending two balls more than 440 feet. Both then hit eight more in a one-minute tiebreaker round.
Still even at 37, they then moved on to a three-swing playoff -- and both hit one each, with Pederson pulling his last hit just foul. They went at it one more time, with Guerrero finally moving on after hitting two homers to Pederson's one.
Before this year's Derby, only six players had hit 40 home runs in an entire event, much less a single round.
"I feel bad for him," an exhausted Pederson said after his final swing. "He's gotta keep hitting; I'm toast."
Pederson, who lost in the final as a rookie in 2015, now has the most combined home runs at the Derby all time, with 99, while Guerrero -- in his first appearance -- tied the previous record of 91 held by Todd Frazier, who also competed twice.
Guerrero had first broken the single-round record in his opening round, blasting 29 to surpass the 28 Josh Hamilton hit in 2008. Hamilton did it during the old "10 outs" format, so he had 38 swings compared to the 48 Guerrero took.
Guerrero easily moved on to the next round after Oakland Athletics' slugger Matt Chapman, a late replacement for the Milwaukee Brewers' Christian Yelich, managed 13 homers while getting fewer good pitches to hit from his father.
Pederson had a slow start to the first round but found a rhythm and advanced by hitting 21 homers to the 16 of the Houston Astros' Alex Bregman, who hit a number of balls to the left-field wall that might have gone out in Houston but came up short in Cleveland.
The Atlanta Braves' Ronald Acuna Jr. did his best Ken Griffey Jr. impression by blowing bubbles in his gum while using all fields to open with 24 homers. That was enough to overcome a respectable output of 18 from the Pittsburgh Pirates' Josh Bell.
In the final quarterfinal matchup, the Cleveland Indians' Carlos Santana had the hometown crowd behind him but found his groove too late in the round and finished with 13. That fell just short of Alonso, who needed 45 seconds to hit his first homer and labored his way to hit his 14th with one second left before his 30-second bonus would have kicked in.
Alonso hit another walk-off homer in the semifinals, launching his 20th of the round over the trees behind the center-field fence as the four-minute clock expired to give him one more than Acuna's 19.
That set up a final between the contestant with the most homers this season -- Alonso had 30 -- and the least.
"I'm happy I didn't face him in the early rounds because he would've knocked me out," Alonso said. "I gotta tip my cap. He's a hell of a hitter, and he's gonna have a really long career. It's unbelievable."
Guerrero did have the honor of hitting the longest homer of the night, 488 feet, in the second round. That netted him a $100,000 bonus to go with his $500,000 for finishing second, which more than equals his season's salary of $468,468.
"I gave all I had. I'm proud I hit 91 home runs," he said.