The Kansas City Royals had waited 29 years to reach the postseason. They weren't going down without a fight.

Salvador Perez singled down the left-field line with two outs in the 12th inning, allowing Christian Colon to score from second base and giving the long-suffering Royals a 9-8 victory over the Oakland Athletics in a wild AL wild-card game Tuesday night.

Quite a start to October baseball -- even if this one appeared to be over in September with plenty of time to spare.

The A's raced out to a 7-3 lead by the sixth inning, but the Royals countered with three runs in the eighth. Nori Aoki's sacrifice fly off Sean Doolittle in the ninth forced extra innings.

The teams kept trading blows over the next couple innings, as midnight came and went on the East Coast and the tension continued to build. Brandon Finnegan finally cracked after tossing two scoreless innings, but the Royals were there to pick up their pitching one last time.

Eric Hosmer hit a rocket to the wall in left field off Dan Otero for a leadoff triple in the 12th, and Colon hit an infield chopper that he beat out for a tying single. That set the stage for Perez, who lined a pitch from Jason Hammel just inside the third-base line to send the Royals pouring out of their dugout in a mad celebration.

The long-suffering franchise hadn't played in the postseason since beating St. Louis in the 1985 World Series, and the excitement the permeated the city might best be summed up by a statement posted by the Kansas City Police on Twitter in about the 10th inning: "We really need everyone to not commit crimes and drive safely right now. We'd like to hear the Royals clinch."

They finally did it in a thrilling start to baseball's playoffs.

For the Oakland, it was one final collapse in a season full of them. The club that once had the best record in baseball wilted over the second half of the season, and needed a victory on the final day of the regular season just to squeeze into the playoffs.

They had chances to put all that in the past. Instead, it will be dragged up for years.

A much-anticipated pitching showdown between Oakland ace Jon Lester and Kansas City counterpart James Shields instead turned into a high-scoring game and a battle of attrition between their bullpens.

Brandon Moss helped the A's strike first, belting a two-run homer in the first inning and a three-run shot in the fifth. The Royals countered by playing small ball, stealing seven bases to tie a postseason record previously shared by the 1907 Chicago Cubs and 1975 Cincinnati Reds, according to STATS.

Kansas City clawed back from a four-run deficit over the final two innings.

The impassioned play by a scrappy bunch of Royals that have rarely tasted success energized a sellout crowd that had been pining for postseason baseball since the 1985 World Series.

Then again, maybe it was the crowd that energized the Royals.

Oakland had built a big lead after the fifth inning, and Lester -- long a thorn in the side of Kansas City -- had started to hit his stride. But A's manager Bob Melvin opted to send him out for the eighth inning, and the Royals finally got Lester into a real jam.

Luke Gregerson entered in relief but failed to provide much. By the time he struck out Perez and Omar Infante to leave runners on second and third, the A's four-run lead had become one.

Doolittle tried to finish the game off in the ninth, but he served up a leadoff single to pinch-hitter Josh Willingham. Pinch-runner Jarrod Dyson was sacrificed to second, and then brashly stole third base, allowing him to score on Aoki's sacrifice fly to right field.

It was the third time in the last three seasons Doolittle has blown a postseason save.

By that point, a series of blunders by the Royals and manager Ned Yost had become moot.

Sean Doolittle tried to finish the game off in the ninth, but he gave up a bloop single to pinch-hitter Josh Willingham. Pinch-runner Jarrod Dyson was sacrificed to second and then brashly stole third, allowing him to score on Aoki's sacrifice fly to deep right field.

It was the third time in the last three seasons that Doolittle has blown a postseason save.

By that point, a series of blunders by the Royals and manager Ned Yost had become moot.

The first occurred in the first inning, when slow-footed designated hitter Billy Butler was caught wandering off first base on an attempted steal with a runner on third. Eric Hosmer broke late for the plate and was thrown out easily to end the inning.

In the sixth, Yost yanked Shields -- the ace of his staff -- and called on Yordano Ventura. The rookie promptly served up Moss' go-ahead, three-run homer.

All that was forgotten as midnight approached at Kauffman Stadium. And now, none of it will be remembered after one of the most dramatic games in franchise history.