CHICAGO – Kyle Gibson tip-toed to the very brink of disaster, inches from an ugly end to Tuesday night's start, perhaps the demise of his spot in the starting rotation, and conceivably even the finish to his Twins career.

"I'm not sure I could imagine some of the things swirling around in his head," manager Paul Molitor said.

And then, abruptly, he turned it around.

Gibson, who gave up six hits and a walk to the first 13 batters he faced, gave up only one more hit to the next 15 batters, turning in his finest performance of the season to lead the Twins to a 4-1 victory over the White Sox.

"I'm really happy for him," Molitor said. Was Gibson one bad pitch from calamity, from demotion, from dismissal? "We'll never know," the manager said with a shrug.

The victory, powered by three home runs from an ever-robust August offense, enabled the Twins to hold on to sole possession of the second wild-card spot in the American League, and pull within 4½ games of first place in the AL Central.

None of that seemed likely as Gibson scrambled to keep runs off the board in the first three innings. He gave up a double to rookie Yoan Moncada in the first inning, and threw a wild pitch to allow him to score. He surrendered singles to three of the first four batters in the second inning, but benefited from a foiled sacrifice bunt, struck out Adam Engel and retired Leury Garcia on a grounder to escape with no damage.

And if Tuesday night somehow represents a turnaround for the fifth-year righthander, historians will be able pinpoint the exact moment Gibson (7-10) executed it. Moncada doubled to open the third inning, Jose Abreu reached on a lucky-bounce infield hit and Nicky Delmonico loaded the bases by walking on six pitches, the last a 3-2 fastball several inches too high.

Nobody visited the mound. Nobody warmed up in the bullpen. Gibson, about as shaky as he has been during a bitterly disappointing season, was left to extricate himself.

How much danger was he in?

"A lot of danger, really," he conceded. "Who'd have thought I'd strike out the side to get out of it? Probably about nobody."

But that's what Gibson did. And he did it, frankly, without throwing strikes — that's how sharp and sneaky his slider was.

He whiffed Avisail Garcia on three pitches, the last two a curveball and a slider, each of which bounced in the dirt but were smothered by Jason Castro. Yolmer Sanchez fouled off two pitches, took a high fastball, then swung at a changeup that might have clipped the bottom of the zone.

By now emboldened, Gibson fed Tim Anderson four sliders, none of them high enough to be strikes, and the shortstop swung and missed at three of them, turning a potential game-breaking rally into a triumph for the beleaguered Twins starter.

"To make the pitches he did, in that situation, he had to feel good about that," Molitor said. "Some of their guys were chasing a little bit. He had a good mix, and it starts with working ahead."

From there, Gibson rolled, facing only three batters in each of the next four innings, erasing Chicago's lone baserunner in that stretch with a quick double play. Gibson, who hadn't thrown a pitch in the seventh inning for exactly a month, left after 91 pitches — "We wanted him to go out on a positive note," Molitor said — striking out eight.

The Twins, meanwhile, spoiled highly touted prospect Lucas Giolito's White Sox debut, and they did it with another home run spree. Jorge Polanco, with five of his 10 career home runs coming in Chicago, connected for the third game in a row, a 408-foot solo shot to lead off the fourth inning. Kennys Vargas led off the fifth inning by smashing a homer to right field on an 0-2 count, the first time in his career he's done that.

And Eddie Rosario drove in Joe Mauer, who had doubled, with a two-run shot to center in the sixth inning, the Twins' eighth home run in the series' three games thus far.