Hayes, battling a tight back all week, hit a three-run homer off major league saves leader Taylor Rogers with one out in the ninth inning and the Pirates beat the Padres 4-2 on Saturday night.
It was the first time the Padres lost in Joe Musgrove's nine starts this season. The big right-hander from suburban El Cajon pitched six strong innings against his former team.
It was the second blown save in 19 chances for Rogers (0-1). Summoned to protect a 2-1 lead, he struggled right away, allowing Michael Perez's double and walking Tucupita Marcano. Rogers struck out Cal Mitchell but then served up Hayes' homer to center field, his first of the season.
''It felt good,'' Hayes said. ''I'd never faced him before so I was just trying to get a pitch up in the zone and keep the line moving. I was fortunate enough to hit it over the fence.''
Hayes said he hit a slider ''that didn't really break. It stayed over the middle of the plate and was a little up. ... I wasn't trying to get too crazy big. I feel pretty comfortable with lefties, and even though he had gotten ahead 0-1, he's pretty much like a two-pitch guy, heater-slider guy, so I wasn't thinking too much. Just trying to look for something out over the plate.''
The Pirates had been 0-24 when trailing after eight innings.
''We did a lot of things well,'' manager Derek Shelton said. ''Obviously, Ke with the big hit there at the end. The guy's leading the National League in saves and has really elite stuff. But they kept grinding. We got out of some big jams. We executed some pitches and then we had some really good at-bats in the ninth.''
Anthony Banda (1-0) escaped a bases-loaded jam in the eighth for the win and David Bednar worked a perfect ninth for his ninth save.
The Padres went ahead 2-1 when Trent Grisham singled home Luke Voit with two outs in the seventh.
San Diego had won each of Musgrove's first eight starts. He held his former team to one run and six hits while striking out seven and walking two.
The Padres continued to struggle offensively, leaving the bases loaded three times and stranding a season-high 16 runners. They played without star slugger Manny Machado, who leads the NL with a .357 batting average. He sat out with tennis elbow that manager Bob Melvin said has been bothering Machado for several days.
Musgrove got out of a bases-loaded jam in the third but the Pirates tied the game in the fourth on two singles and a dribbler. With Josh VanMeter on third and Jack Suwinski on first, Perez hit a one-out dribbler down the first base line. Musgrove scooped it with his glove to catcher Austin Nola, but VanMeter scored and Perez reached as Nola's throwing error allowed Suwinski to advance to third.
Voit opened the seventh with a walk off Dillon Peters and advanced on Jake Cronenworth's groundout. Peters was hit on the left foot by Cronenworth's comebacker, made the play at first and then came out. Voit scored on Grisham's single to right off Chris Stratton.
Nola hit a sacrifice fly in the second. The Padres loaded the bases with two outs before Kim Ha-seong struck out.
Pirates left fielder Ben Gamel robbed Eric Hosmer of a home run with a leaping grab against the fence and then fell flat on his back. Pittsburgh starter JT Brubaker raised his arms in celebration.
Brubaker allowed an unearned run and six hits in five innings. He struck out three and walked two.
Pirates: Gamel came out of the game after stealing second in the eighth.
Padres: Melvin said Machado lobbied to play but ''this is something we need to calm down because it's not getting any better.'' Machado is day-to-day.
The series concludes Sunday when Pirates RHP Roansy Contreras (1-0) opposes rookie LHP MacKenzie Gore (3-1, 2.06 ERA).
More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.