Lorenzo Brown had 16 points, eight assists and five steals for the Wolfpack (3-0), including the feed to Painter near the top of the circle for the winning basket. Princeton had a final chance after a timeout, but Ian Hummer's desperation heave from near halfcourt fell short as time expired for the final play in a tense finish.
Painter finished with 11 points. C.J. Williams and Richard Howell each scored 10 as the Wolfpack rallied from a nine-point deficit in the first half and a 35-32 halftime deficit.
Douglas Davis scored 21 points for the Tigers (0-2) and hit five 3-pointers, the last to tie the game with 20.6 seconds left and set up Painter's final shot.
The Wolfpack had to play most of the way without junior outside shooter Scott Wood, who injured his right ankle barely 2 minutes in and didn't return.
N.C. State also played for the third straight time without sophomore forward C.J. Leslie and freshman forward Thomas de Thaey, with Leslie serving the last of a three-game suspension for receiving improper benefits while de Thaey is out indefinitely while the school reviews the Belgium native's eligibility from overseas.
The Wolfpack opened the season with relatively easy wins against UNC Asheville and Morehead State, giving new coach Mark Gottfried a successful debut with a faster-paced offense and some improved play inside from Painter and Howell. This time, however, N.C. State ended up with a fight on its hands to the final horn.
Alex Johnson, who had struggled with his shot so far this season, appeared to have the Wolfpack poised to win when he hit a 3-pointer from the right corner for a 58-55 lead with 1:55 left. But Davis lost Brown on the right side and launched a 3 that swished through the net and tied the game in the final minute.
Painter's 18-footer, however, helped keep Gottfried unbeaten at N.C. State.
The game is part of the Legends Classic. N.C. State travels to East Rutherford, N.J., to face No. 18 Vanderbilt in the semifinals.