Cain hit a tying, two-run homer off Jose Valverde with two outs in the ninth and Eric Hosmer had a winning RBI single in the 10th, helping the Royals rally for a 3-2 victory over the Detroit Tigers on Wednesday.
Cain struck out three times against Detroit ace Justin Verlander, who pitched seven scoreless innings.
"It was a crazy game from having the hat trick to being able to get a ball out of here was huge," Cain said. "I was glad I was able to get a good pitch and get it over the fence for us to tie the game up."
Drew Smyly pitched a one-hit eighth, then allowed a leadoff single in the ninth to Hosmer and was replaced by Valverde. He retired Santiago Perez on a flyout and struck out Billy Butler as Hosmer stole second -- becoming the first Kansas City runner in scoring position.
Cain fouled off three pitches, then sent an 85 mph offering over the wall in left-center. Valverde blew a save for the third time in 12 chances.
Cain was not sure it was going to clear the fence.
"I put it on the barrel, but after that it was either wind or carry," Cain said. "I thought it was in the gap. I was just blowing for it to go out for me and it did."
Verlander did not allow a batter past first base, giving up three singles, striking out eight and walking two in a 117-pitch outing, his second-highest total this season.
"It was a tough outing, Verlander being Verlander as usual, dominating," Cain said. "I say continue to battle, got a pitch up, put a nice easy swing on it and it got over the fence."
Verlander has a 15-2 record with a 2.56 ERA in 25 starts against the Royals.
"It hurts," Verlander said. "You've got two outs and two strikes, and when the ball leaves the yard, it's not a good feeling. It only tied the game, so we immediately need to change our mindset to OK, let's win it. To lose it that way, it's a tough pill to swallow.
"Losing period stinks. When you lose one that's so close to a win makes it that much more difficult."
Greg Holland (2-1) pitched a perfect 10th, striking out Torii Hunter and Miguel Cabrera and retiring Prince Fielder on a lineout, and Miguel Tejada singled off Phil Coke (0-4) leading off the bottom half.
"That was a great win," Hosmer said. "We're down to our last strike with the closer on the mound. That's just the character of this team. We're not going to give up until the last out is made.
"Cain had a day like he did, the first couple of at-bats, strikes out. The way he comes up in the last inning with two strikes, it's battling right there."
Tigers manager Jim Leyland's post-game press conference was brief, lasting 97 seconds.
"Verlander showed why he's the horse today," Leyland said. "He was terrific, absolutely terrific. He stepped up today. That's the way he's been the seven years I've been here."
But the Tigers' bullpen remains an Achilles' heel with a 4-12 record and eight blown saves.
"He (Valverde) got two quick outs and then he hung a splitter," Leyland said. "He left it out over the plate. It didn't split and the kid hit it out. The key was the ninth inning. We got two quick outs and two strikes and the guy hit it out."
James Shields, acquired from Tampa Bay in a December trade, allowed two runs and six hits in seven innings for the Royals. He is 0-4 in eight starts since beating the Rays on April 30 despite a 2.64 ERA in that span.
Detroit built its lead on Fielder's RBI single in the first and consecutive doubles by Matt Tuiasosopo and Brayan Pena in the fifth. Pena, who played the four previous years with Kansas City, has three doubles, two homer and 10 RBIs in his past 16 games.
Royals right fielder David Lough robbed Cabrera of a run-producing extra-base hit in the third when he made a diving catch of his liner to the gap with Hunter on first. Lough received a standing ovation from the Kauffman Stadium crowd of 24,564, while Shields tipped his cap and waited for Lough in front of the Royals dugout to congratulate him.
"If you rate it a 15 on a 10 (scale), that's how I would rate his catch," Shields said. "It's a very crucial part of the game. That's going to be up there for catch of the year as far as I'm concerned."
Royals manager Ned Yost will miss the game Thursday at Tampa Bay to attend his daughter's wedding. Bench coach Chino Cadahia will manage in Yost's absence. ... Tigers RHP Anibal Sanchez, who sat out his previous start with shoulder tightness, is scheduled to start Saturday at Minnesota. ... The Tigers had three sacrifice bunts, including two by Ramon Santiago. They had only eight in their first 64 games.