Cespedes, an outfielder from Cuba who plays for the Oakland Athletics, beat Harper 9-8 in the final round at Citi Field, hitting the decisive, 455-foot (138-meter) drive with five swings to spare. It was his 32nd homer of the night.
Competing in the contest in only his second season in Major League Baseball, Cespedes hit a whopping 17home runs in the first round — more than any other player managed in their first two trips to the plate.
"I felt that I was getting into a very good rhythm, and that as long as the ball was right over the plate, I felt like I was in a good groove," Cespedes said through a translator. "That was the key."
The final addition to the field, Cespedes was the fourth player not selected for the All-Star game to compete in the event. The 27-year-old has struggled this season, batting only .225 with 15 home runs.
The 20-year-old Harper hammered eight homers in all three rounds, but the Washington Nationals star couldn't keep up with Cespedes.
"He's incredible," Harper said. "He's an absolute machine."
Colorado outfielder Michael Cuddyer and Baltimore first baseman Chris Davis, who leads the majors with 37 homers this season, were eliminated in the second round. Davis tied Reggie Jackson for the American Leaguehome run record before the All-Star break.
Also knocked out early were defending champion Prince Fielder, the only player besides Ken Griffey Jr. to win multiple Home Run Derby crowns, and American League captain Robinson Cano of the New York Yankees, who made Cespedes his final pick.