DETROIT (AP) -- Doug Fister was breezing along after striking out nine straight batters and setting an American League record.
Detroit led by four runs in the eighth inning - but for the 2012 Tigers, nothing has come easy.
The Tigers nearly wasted Fister's dazzling streak, blowing a big lead late before beating Kansas City 5-4 on Thursday when Alex Avila drove home the winning run in the ninth with a bases-loaded grounder.
Detroit's lead in the AL Central grew to two games when the slumping Chicago White Sox lost to Tampa Bay 3-2.
''Getting a win is big,'' Avila said. ''We have to be able to win tight games like this. It's the only way we're going to be able to get in the playoffs and go far in the playoffs.''
Detroit finished 50-31 at home this season - and will now try to wrap up the division on the road. The Tigers play three games at Minnesota, followed by a season-ending three-game series at Kansas City.
Fister came within one strikeout of matching Tom Seaver's major league record of 10 in a row. He struck out Salvador Perez to end the top of the fourth, starting a streak that didn't end until Perez grounded out to the shortstop on a two-strike pitch in the seventh.
''It's crazy, to go through a whole lineup and strike everybody out,'' Royals outfielder Jeff Francoeur said. ''And I don't think he threw more than four pitches to any of the batters.''
The AL record of eight consecutive strikeouts had been accomplished several times, most recently by Kansas City's Blake Stein on June 17, 2001.
After Perez grounded out for the third out of the seventh, first baseman Prince Fielder put his arm around Fister as they headed back to the dugout.
''I said, 'Congratulations, man. You made history.' He was like, 'What are you doing?''' Fielder said. ''He was locked in so it was kind of like, 'Get away from me.' I was like, 'All right, they'll tell you.''
At that point, Fister had retired 16 straight hitters and Detroit led 4-0 - but he was oblivious to the strikeout record.
''Honestly, I had no idea,'' Fister said. ''(Fielder) was yelling at me to step off during the inning, and I kind of looked at him. Normally, he'll do that, to slow me down, if I'm getting too quick. ... I thought that was kind of what he was doing there. He just said, 'Hey, step off.' I look at him, and he kept looking at me, and he said, 'Aw, I'll tell you later.'''
Fister's performance almost went for naught. The Royals scored three runs in the eighth, and Billy Butler tied it in the ninth with a solo homer off Joaquin Benoit (5-3).
Fielder led off the Detroit ninth with a chopper that went past the mound and charging shortstop Tony Abreu. The hefty slugger made it all the way to second for a double on a ball that only ended up a few feet beyond the infield.
Delmon Young was intentionally walked, and pinch-hitter Ramon Santiago bunted into a forceout at third, leaving runners at first and second. Kelvin Herrera replaced Tim Collins (5-4) on the mound and got Jhonny Peralta to hit what looked like a potential double play grounder to third, but Mike Moustakas misplayed it for his third error of the game - and Kansas City's fifth.
Avila hit a full-count pitch to first baseman Brayan Pena, who made a diving stop and touched the bag, but had no play at home.
''Pena still made a great play on that one,'' Fielder said. ''Baseball is really hard because even if you're good, you have to be a little lucky, too.''
Fister finished with 10 strikeouts in 7 2-3 innings. He allowed two earned runs and five hits.
Kansas City's Luis Mendoza allowed two earned runs in seven innings.
Francoeur hit an RBI double in the eighth, Johnny Giavotella added an RBI groundout, and Abreu, pinch-hitting, drove in a run with a single to make it 4-3.
Detroit took a 4-0 lead thanks in part to four Kansas City errors in the first two innings.
Moustakas was charged with two errors on one grounder by Quintin Berry - one for mishandling it and another for a bad throw. Fielder drove in a run later in the first with a single, advancing to second on an error by left fielder Alex Gordon.
Young hit a sacrifice fly, and Gordon threw Fielder out at home on a single by Andy Dirks to end the inning.
Berry's two-run triple in the second made it 4-0.
NOTES: Detroit closer Jose Valverde was sick and unavailable. ... Royals 1B Eric Hosmer left the game with a strained right shoulder. ... The Tigers play at Minnesota on Friday night. LHP Drew Smyly (4-3) will start because of an injury to Max Scherzer. Minnesota will counter with LHP Scott Diamond (12-8).