Chicago tied the game at 3 in the eighth inning on back-to-back one-out doubles by Leury Garcia and Yoan Moncada.
Avisail Garcia led off the ninth with a single and was sacrificed to second. Following an intentional walk to Yolmer Sanchez, Anderson produced the first walk-off hit of his career.
Jorge Polanco homered for the fourth straight game and drove in two runs for the Twins.
Danny Farquhar (3-2) pitched a scoreless ninth for the win. Trevor Hildenberger (2-2) took the loss.