Updated

SAN FRANCISCO -- Mike Moustakas hit his 18th home run leading off the second inning, Jorge Bonifacio and Lorenzo Cain followed with back-to-back shots in the third and the Kansas City Royals beat the San Francisco Giants 7-2 on Wednesday to complete a two-game sweep.

Bonifacio finished with two hits and three RBIs, Whit Merrifield added three hits and three runs while Alcides Escobar singled three times to help Jason Hammel end an eight-game winless stretch on the road that dated to 2016.

Hammel (3-6) allowed one run over 6 2/3 innings to beat the Giants for the first time in 12 starts. The right-hander gave up eight hits, struck out four and walked one.

Moustakas, one of Kansas City's top hitters over the past two weeks, stayed hot with his home run off former Royals pitcher Johnny Cueto (5-6) that landed in the waters of McCovey Cove. It was the fifth homer in 12 games for Moustakas, who is already just four shy of his career high.

Bonifacio homered in the third after Merrifield opened the inning with a bunt single. Two pitches later, Cain lined an 0-1 pitch over the fence in left-center that put the Royals up 4-0.

Kansas City has scored seven or more runs in each of its last four games, all wins.

Cueto struggled in his first appearance against his former team since signing with San Francisco after helping Kansas City to the 2015 World Series. Cueto allowed five runs and 10 hits over 5 2/3 innings. Cueto walked three and struck out five.

Eduardo Nunez had two hits and an RBI for San Francisco. The Giants have lost 11 of 15.

San Francisco had two on and two outs twice but failed to score each time. Hammel fanned Brandon Crawford to end the fourth and reliever Peter Moylan got Buster Posey to ground out to end the seventh.

TRAINER'S ROOM

Giants: 2B Joe Panik returned to the lineup after being sidelined for four games with a sprained left thumb he injured last week in Milwaukee diving for a ground ball.

UP NEXT

Royals: LHP Matt Strahm (1-3, 4.05) makes his first career start Thursday in Anaheim against the Angels. Strahm has made 20 appearances out of the bullpen this season.