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
Royals sign former All-Star Trevor Rosenthal to minor league deal
The Kansas City Royals signed former All-Star reliever Trevor Rosenthal to a $2 million minor league contract that includes an invitation to big league spring training and up to $2.25 million in bonuses if he makes the major league roster.
Yankees GM rappels building, gets fan's message on Gerrit Cole
Brian Cashman saw a message taped to a 10th-floor window while prepping for a festival in Connecticut. "Please sign Gerrit Cole," it said. The GM's response: "I'm open to do clearly whatever, as always, is important for the Yankees."
Rays' Blake Snell strongly reacts to Tommy Pham trade on Twitch
Rays pitcher Blake Snell apologized for his reaction -- captured during a livestream on Twitch -- to news that teammate Tommy Pham was traded to San Diego.
What's next for the teams that lose the Gerrit Cole sweepstakes?
One team will land the best pitcher on the planet. The rest of his suitors? They'll have to scramble.
Source: Nationals agree to deal with World Series hero Howie Kendrick
Howie Kendrick, who capped the Nationals' improbable run to their first World Series title last season with a Game 7 home run, has reached an agreement on a one-year, $6.25 million deal to return to Washington, a source told ESPN's Jeff Passan on Friday.
Win-now Padres pay steep price for Tommy Pham
San Diego took another step toward contending in 2020 by adding the outfielder but shipped one of its best prospects to Tampa Bay in the process.