Alexei Ramirez also went deep, and Chicago came away with the win after wiping out an early three-run deficit and then rallying again.
They were trailing 5-4 going into the ninth when Dayan Viciedo led off with a single.
Dunn then won it when he drove an 0-2 pitch out to right-center for his eighth homer. It was the 10th time he has ended a game by homering, and the first for him since July 4, 2013, against Baltimore.
That made a winner of Daniel Webb (4-0), who pitched 1 1-3 scoreless innings, and gave Robertson (0-1) his first blown save in 10 chances.
Derek Jeter singled twice, walked and scored while tying Luis Aparicio for second in games played at shortstop with 2,583.
Ramirez and Adam Eaton each had three hits for Chicago and the White Sox won for the fourth time in five games.
The Yankees looked as though they might be on their way to an easy win when Brian McCann connected off Hector Noesi in the first. It was a good start for New York after managing just one baserunner in six innings against Chris Sale in Thursday's loss, but things quickly took a difficult turn.
The Yankees gave up unearned runs in the first and fourth, and Chicago took a 4-3 lead on Ramirez's two-run homer off Hiroki Kuroda in the fifth.
Roberts then scored when Petricka bounced a pitch to Ellsbury, who then drove in Soriano with a sacrifice fly to center to give the Yankees a 5-4 lead.
Kuroda allowed four runs (two earned) and eight hits in 4 2-3 innings. He is 0-7 in 11 road starts since a win at Texas on July 25.
Noesi, a former Yankees prospect who got dealt to Seattle in the Michael Pineda trade in January 2012, allowed three runs and four hits. He walked five, but was in line for his first win since he beat Minnesota while with the Mariners on May 6, 2012, before the bullpen gave away the lead.
NOTES: Jeter and Aparicio trail Omar Vizquel (2,709) in games played at shortstop. ... The White Sox plan to honor Jeter before Sunday's game with a video tribute and commemorative gifts. ... White Sox ace Chris Sale had no setbacks after a dominant return to the rotation on Thursday. Manager Robin Ventura said the left-hander was feeling ''great'' a day after retiring 18 of 19 batters. Sale had missed nearly five weeks because of a flexor strain in his pitching arm.