Cain's RBI single in the first inning opened the scoring and his run-scoring hit in the fifth put Kansas City ahead for good at 3-2.
The Royals center fielder made it 5-3 with an RBI double in the seventh as Kansas City evened its three-game series.
Yuniesky Betancourt knocked in two runs for the winners.
Mendoza (4-6) allowed three runs on seven hits over 6 1/3 innings, striking out four and walking two.
Minnesota starter Scott Diamond (8-4) was touched for four runs on 10 hits over six full frames.
Chris Parmalee went 2-for-4 with an RBI for the Twins.
Attkisson leaves CBS News, reportedly over network's 'liberal bias'
Ohio bar shooting arrested, charged with murder