CHICAGO -- Several missed opportunities resulted in another frustrating loss to a non-contender for the Chicago White Sox.
Salvador Perez also hit a two-run homer for the Royals, who won their sixth straight against Chicago.
"They've always had a really good bullpen and they've always been able to swing the bats. Of late, they've been really good pitching, starting-wise, so they're just as formidable as anybody," Chicago's Paul Konerko said of the Royals. "We realize that, and we certainly don't go into games taking them lightly, so it's no surprise to us."
Kelvin Herrera (2-2) pitched out of a bases-loaded jam in the eighth inning for the Royals.
Johnny Giavotella led off the ninth with a single off Addison Reed (3-2). Cain followed with a deep home run to left center, giving the Royals a 7-5 lead. His seventh home run of the season gave him his first career two-homer game.
Greg Holland pitched the ninth for his 12th save in 14 chances.
The White Sox left the bases loaded in the first and eighth innings. Herrera got Jose Lopez to pop out in the eighth.
"We can get them on, but we are having problems getting them in," White Sox manager Robin Ventura said. "It's one of those games where you had plenty of opportunities and don't knock them in. Then you give them opportunities by giving them free baserunners."
With Adam Dunn and Kevin Youkilis missing from the top of the order, the White Sox jumped on starter Luis Mendoza early. Alejandro De Aza led off the first with a single and moved to second on Lopez's groundout. After Wise walked, Konerko drove in De Aza with a single.
Billy Butler led off the second with a bloop single, and Perez extended his hitting streak to 12 games with a two-run homer to left. It was his ninth of the season.
Trailing 2-1, Wise led off the third with a triple, but failed to score. Konerko flied out to shallow right field then Rios followed with another pop fly to shallow right. Giavotella, playing second base, made the catch on Rios' ball with his back to the plate and Wise tried to tagged from third, but Giavotella made a good throw to the plate to easily get Wise.
Pierzynski tagged Mendoza with a leadoff home run in the fourth to tie the game at 2. It was his 25th of the season.
With two outs in the fifth, Cain homered on a slider from starter Francisco Liriano to give the Royals a 3-2 lead.
"(Liriano) was eating me alive with the changeup," Cain said. "I couldn't touch it, I couldn't see it, I couldn't do anything with it, but he ended up hanging a slider right down the middle of the plate, put a good swing on it and I was able to get it out."
Wise came back with a solo shot in the fifth to tie the game 3-3. It was his seventh of the season.
Ventura pulled Liriano after he issued consecutive walks in the sixth. Jeff Francoeur greeted reliever Nate Jones with an RBI double down the right-field line to put the Royals ahead. Eric Homer gave Kansas City a 5-3 lead with a sacrifice fly.
Liriano has walked 15 batters in his past 14 innings. It was his third straight start that he couldn't record an out after the fifth inning.
"I tried to throw the ball over the plate (in the sixth) and it was running everywhere," Liriano said. "I feel like I'm not doing my job right now. It's kind of frustrating.".
After a leadoff single by Dayan Viciedo in the sixth, Ramirez tied the game 5-5 with his ninth homer of the season.
Liriano was tagged for five runs and six hits with four walks in five innings.
Mendoza didn't fare much better. He was pulled after allowing five runs and 10 hits in 5 1/3 innings.
Dunn (strained right oblique) was out after missing two games due to the same injury. Ventura said he hopes Dunn can return Saturday or Sunday. ... Youkilis left the team to be with his wife, who is expecting to give birth to their first child. Ventura said he hopes Youkilis returns this weekend. ... RHP Gavin Floyd (right elbow flexor strain) threw sliders, changeups and fastballs in a 55-pitch bullpen session Thursday. He plans on throwing curveballs in another session on Sunday and hopes to rejoin the White Sox rotation soon after. ... Gordon set a career-high with his 46th double in the third inning.