Greinke (6-2), who recorded his 2,500th career strikeout in the fourth, was working on a one-hit shutout when he ran into trouble in the sixth. Ian Kinsler singled with one out, advanced on Franmil Reyes' groundout and scored on Manny Machado's single. Hosmer then drove Greinke's next pitch to left field to give the Padres the lead. It was Hosmer's seventh.
"He's a guy you don't want to fall behind," Hosmer said. "We were aggressive early. We didn't miss those pitches. Ian got things going, Manny did a good job of being aggressive early and then I got a pitch to hit early in the count as well and didn't miss it. Outer half, that's where I'm always looking, trying to get something where I can get a little bit of extension going. Didn't miss it, that's that fortunate part."
The Padres won their second straight to pop back above .500. The Diamondbacks lost their fourth straight.
"It felt good to win," Hosmer said. "We're facing a team that's ahead of us right now in the division. Anytime we're playing these games we know how important they are. Against a guy like Greinke you know you're not going to have many opportunities, so it was big for us to get it going that inning."
Said Greinke: "First pitch fastball to Hosmer, probably a little bit higher than I wanted. Good swing, hit it really good and bad results."
Overall, though, he felt good about his command.
"Even the hits they got were located pretty well. Their best hitters got the hits and did a good job."
Left-hander Matt Strahm (2-3) allowed two solo homers among his four hits in six innings. He struck out two and walked none.
Kirby Yates struck out the side in the ninth for his 19th save.
Greinke allowed three runs and four hits in seven innings, struck out five and walked one. He was trying for his third win against the Padres this season. He beat them 8-5 at Petco Park on April 2, when he struck out 10 and hit two home runs.
He got Franmil Reyes swinging leading off the fourth for career strikeout 2,500.
"Haven't thought about it at all," Greinke said about the milestone strikeout. "Didn't even know it happened. A lot of times you guys can find records in every game if you try hard enough."
Manager Torey Lovullo was impressed.
"Zack was once again outstanding. He got his 2,500th strikeout. That's hard to do," the manager said. "I think we all need to sit back and appreciate exactly what that means and who's throwing for us every fifth day. He's a very special pitcher and he had everything working today. It just was a really, really good outing for him and it all blew up quickly there. He doesn't give up many home runs. He keeps a lot of balls in the ballpark."
Diamondbacks: Left fielder David Peralta came out of the game with right shoulder soreness. ... INF Wilmer Flores was placed on the 10-day injured list with a bruised right foot, retroactive to Monday, and Ildemaro Vargas was recalled from the Triple-A Reno.
Padres: C Francisco Mejia (left knee strain) started a rehab assignment with Triple-A El Paso.
Diamondbacks: RHP Merrill Kelly (4-4, 4.21) is scheduled to start the series finale Wednesday afternoon. He won his MLB debut at Petco Park on April 1.
Padres: LHP Eric Lauer (2-4, 5.24) is scheduled to make his club-leading 10th start.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
How should MLB players handle uncertainty surrounding season?
Alex Rodriguez shares his thoughts on how MLB players should prepare for a shortened season, whenever it might start.
Bat from Yankees legend Lou Gehrig goes for $1M
A bat used by Yankees legend Lou Gehrig commanded more than $1 million at a Dallas auction house.
How Hank Aaron inspired in the chase to break Babe Ruth's HR record
Jackie Robinson's daughter Sharon narrates an essay on Hank Aaron and the discrimination he endured chasing the all-time home run record held by Babe Ruth.
Mets simulation broadcast throws shade at Astros
The SNY broadcast team of Gary Cohen, Keith Hernandez and Ron Darling took some shots at the Astros during a video game simulation of a matchup against the Mets.
MLB draft rankings: The top 100-plus players available in 2020 and beyond
This year's five-round draft will have an impact on college stars like Spencer Torkelson. Plus, early rankings for the 2021 and 2022 classes.
'We're all just trying to help each other': How video games are bringing MLB players and fans together
With the routine of baseball broken by a global pandemic, MLB stars have turned to livestreaming on Twitch, building unique relationships with their fans.