The All-Star third baseman went 1 for 3 with three RBIs and a run scored in the 8-3 triumph Thursday at PNC Park in Pittsburgh.
Pittsburgh and San Diego split the four-game series.
Padres center fielder Tim Grisham hit a leadoff single in the first at-bat of Thursday's game. Pirates starter Mitch Keller then forced Jurickson Profar to fly out to center field. Padres second baseman Jake Cronenworth followed with an RBI double for a 1-0 lead.
Machado then stepped into the box to face Keller. The Pirates right-handed pitcher quickly earned a 1-2 advantage in the count, but Machado fouled off several pitches to stay alive.
The Padres slugger smacked the seventh offering of the exchange right up the middle for a 374-foot two-run homer. Machado's home run left the field in 4.9 seconds, according to Statcast.
Padres right fielder Tucupita Marcano plated Eric Hosmer with an RBI double for the final run of the inning.
Hosmer returned to the plate in the second inning and plated Profar and Cronenworth with an RBI single for a 6-0 Padres lead.
Third baseman Eric Gonzalez got the Pirates on the board with an RBI double in the bottom of the second frame.
Cronenworth brought in the seventh Padres run with an RBI sacrifice fly in the fourth inning. The Pirates made the score 7-3 when they scored two runs on a fielding error in the fifth frame.
Machado then brought in the final run of the game with an RBI sacrifice fly in the top of the sixth inning.
Padres starter Chris Paddack allowed five hits and three runs in five innings to move to 1-1 on the season. Keller allowed nine hits and seven runs and dropped to 1-2 this season.
Relief pitcher Craig Stammen earned his first save of the season. Stammen allowed three hits and no runs over the final three innings.
Cronenworth went 2 for 2 with two RBIs, two runs scored and two walks. Hosmer went 2 for 5 with two RBIs and a run scored for the Padres. Profar and Grisham collected two hits apiece in the victory.