The Twins had one foot in the clubhouse Friday night. Fans were ready for the scheduled postgame fireworks.

Then it all unraveled in the ninth with Glen Perkins, of all pitchers, on the mound.

Fortunately for the Twins, Brian Dozier has come into his own, and he was there Friday to untangle the Twins from a big mess.

Chicago scored twice off Perkins in the ninth to tie the score, and more runs were coming before Dozier began a huge inning-ending double play. Then Dozier stroked a two-out RBI single in the bottom of the ninth, scoring Eduardo Escobar from second with the winning run in a 5-4 victory over the White Sox.

Perkins retired the first batter he faced in the ninth, but Dayan Viciedo hit a deep fly to left that was misplayed by Josh Willingham into a triple. That was the first of four consecutive hits off Perkins that scored two runs to tie the score.

Manager Ron Gardenhire had Perkins walk Gordon Beckham intentionally to load the bases for Chicago’s No. 3 hitter, Conor Gillaspie. And Jose Abreu, who hit his 21st homer of the season in the first inning, was on deck.

“I don’t ever really like to walk anybody and force [Perkins] to do that,” Gardenhire said, “but I felt we had to go that way and take a shot.”

It was up to his infielders, playing halfway, to make the right read. Go for two or the safer force play at home? Gillaspie put that decision in Dozier’s hands with a ground ball to his left.

“My first step was to go home because it bounced so high,” Dozier said. “Then it was to my left just a tad. Something clicked to stay back on it and turn and throw it.”

Shortstop Danny Santana caught the throw at second and needed all of his strong arm to throw Gillaspie out at first to end the inning. Twins players bounced into the dugout pumping their fists.

Escobar and Sam Fuld drew one-out walks in the bottom of the ninth off Daniel Webb (4-1). Scott Downs entered and got Santana to line out to left for the second out. White Sox manager Robin Ventura replaced Downs with his closer, Ronald Belisario, to face Dozier.