The Australian trailed 3-1 and 6-5 to Painter, who hit five 180s in the first half of the contest only to see Whitlock win four successive legs to swing the game in his favour at 9-6.
Painter threatened to hit back, taking out 122 at one stage, but Whitlock followed an earlier key 96 finish by taking out 91 to seal the victory.
"I^m over the moon," said Whitlock. "That was such a tough game - Kevin^s a warrior who^s been around for so many years and he^s a legend.
"I^ve watched him play for the last 20 years and I^m very happy to win that match. There was a big moment in the 14th leg where Kevin missed and I levelled to go to seven-all, and I knew that was my chance."
BetVictor World Matchplay
Tuesday July 22
Second Round
Raymond van Barneveld (8) 9-13 Justin Pipe (9)
Simon Whitlock (5) 13-10 Kevin Painter (12)
Phil Taylor (1) 14-12 Terry Jenkins (16)
James Wade (4) 13-9 Gary Anderson
Simon Whitlock v Kevin Painter
0-0 - Simon Whitlock wins the bull and throws first.
0-1 - Painter breaks throw immediately by hitting tops with his third dart.
1-1 - Whitlock finishes 85 to break back.
1-2 - Painter lands a 180, and capitalises on a miss from Whitlock by hitting double 14 to break again.
1-3 - Painter secures the game^s first hold of throw by landing double ten.
2-3 - Whitlock opens with a 177 and hits double five to pull back to one leg behind.
3-3 - Whitlock posts double ten to level the game.
3-4 - Whitlock hits a 171 of three treble 19s, but misses the bull for a 132 finish and two further doubles to allow Painter in on double eight.
4-4 - The pair trade 180s before Whitlock takes out 96, hitting a single 20 and two treble 19s to show some fine dexterity around the dartboard.
5-4 - Whitlock hits double ten to hit the front for the first time.
5-5 - Painter posts a 180 and tops to square the contest.
5-6 - Painter hits a 180, and is given a reprieve for two misses at tops when he returns to hit double ten for yet another break, after Whitlock misses double 16 for a 108 checkout.
6-6 - Painter misses two darts to capitalise on a missed bullseye from Whitlock, who returns to land double eight.
7-6 - Painter misses two more darts at doubles, and Whitlock hits tops to move back ahead.
8-6 - Whitlock wins a third straight leg by hitting tops.
9-6 - Whitlock lands a second 180 of the game, and double ten puts him three legs clear.
9-7 - Painter hits back on double top to win his first leg in five.
10-7 - Whitlock takes out 74 on double 12 to regain his cushion.
10-8 - Whitlock is unable to take his chance to move four legs clear, and Painter lands double eight to hit back.
11-8 - Painter misses the bullseye, and Whitlock finishes double eight to edge closer to victory.
11-9 - Whitlock hits a 180, but Painter replies on tops.
12-9 - Whitlock kicks off with another maximum, and hits double 18 to move a leg away from the win.
12-10 - Painter takes out 122 on double seven to keep his hopes alive.
13-10 - Painter is unable to take out 129, and Whitlock finishes 91 on double 16 for the win.