DETROIT (AP) -- Eric Hosmer has been trying to find his way out of a long slump, and coming to Detroit may have done the trick.
A night after homering in a win over the Tigers, Hosmer spent most of Wednesday torturing the Comerica Park crowd.
He walked in the fifth inning to break up Anibal Sanchez's perfect game, doubled in the seventh to end Sanchez's no-hit bid, then hit a tie-breaking two-run homer in the ninth to lead the Kansas City Royals to a 4-1 victory over Detroit and a three-game sweep.
"I don't think we've swept a series here in my career - we haven't even won more than a couple," he said. "I've been struggling for about a month now, but it has started to come around, and tonight felt really good."
Sanchez threw seven shutout innings after allowing eight runs in four innings in his previous start. He struck out six and walked two Wednesday.
"That's as good as I've ever seen Anibal Sanchez throw the ball," Royals manager Ned Yost said. "I had seen what he had done in his last start, but I know that when he's on, he has ridiculous command of his fastball and a phenomenal changeup. That's what he had tonight."
"Today, everything was coming out good," he said. "I felt good all game, and I just wanted to keep the score at 1-0. I wasn't thinking about the no-hitter."
The Tigers have lost eight of their last 10 games.
"I'm not whining - we have to come out and win a game tomorrow," Tigers manager Brad Ausmus said. "They came up with big hits late tonight and we didn't. That was the difference."
Justin Wilson replaced Sanchez for the eighth with a 1-0 lead and allowed a tying homer to Alex Gordon on his first pitch.
In the ninth, Shane Greene (2-3) allowed a one-out single to Lorenzo Cain before Hosmer's line drive into the right-field stands. Drew Butera added an RBI single later in the inning.
"I made a bad pitch to a good hitter," Greene said. "It was a cutter and I tried to get too perfect with it. It happens."
Matt Strahm (1-0) got his first career win with 1 2/3 scoreless innings of relief, and Kelvin Herrera pitched the ninth for his sixth save.
Victor Martinez gave the Tigers a 1-0 lead in the second with a homer over the 365-foot sign in right-center field. Detroit had 11 more baserunners, but hit into two double plays and stranded nine.
The Royals didn't come close to getting a runner in the first four innings, but Hosmer and Gordon both drew walks in the fifth.
Sanchez got through the inning without a hit, but was already at 80 pitches, and he came into the game having allowed a 1.080 OPS after his 75th pitch.
Sanchez got through the sixth on eight pitches, then retired the first two batters in the seventh without trouble, but Hosmer lined a first-pitch curveball into the left-center field gap to end the drama.
Royals: RHP Kris Medlen, sidelined since May 21 with rotator-cuff inflammation, threw two scoreless innings in a Rookie-level Arizona League game. ... LHP Jason Vargas, who has missed the entire season after Tommy John surgery, was scheduled to start Wednesday night for Double-A Northwest Arkansas.
Tigers: Miguel Cabrera returned after sitting out Tuesday's loss with a strained left biceps. He didn't look entirely comfortable, shaking his arm after swings, but hit a 112 mph groundball in the third inning, per Statcast. ... LF Tyler Collins left the game after seven innings with a right-knee contusion. He had been hit by Yordano Ventura's 99 mph fastball in the sixth, and Ausmus said he's expected to miss a few games.
Erick Aybar got a loud cheer from the Comerica Park crowd when he batted for the first time as a Tiger - a change from his usual greeting in Detroit. In 2011, Aybar bunted to try to break up Justin Verlander's no-hitter in the eighth inning, drawing an angry response from both the Tigers ace and the fans.
Verlander joked that the Tigers trading for Aybar on Tuesday made him glad he didn't retaliate.
"I told him I was going to hit him, but I never did," Verlander said. "So that will make things easier in the clubhouse."
Royals: Kansas City returns home to start a four-game series with the Twins on Thursday night. Dillon Gee (4-6, 4.78) is scheduled to start against Minnesota's Tyler Duffey (8-8, 5.71).
Tigers: Detroit plays Boston on Thursday in the first of a four-game series. Matt Boyd (4-2, 4.16) faces Clay Buchholz (4-9. 5.66) in a game being played during the afternoon because of a Detroit Lions exhibition game at nearby Ford Field in the evening.