JaJuan Johnson added 14 points and Robbie Hummel had 12 points, 13 rebounds and five assists for the Boilermakers (17-3, 5-3 Big Ten), who won their third straight and moved within a half-game of Wisconsin for second place in the conference.
A loss would have left Purdue four games behind league leader Michigan State with 10 to play.
Trevon Hughes missed a contested runner in the closing seconds that could have won it for Wisconsin. Keaton Nankivil scored a career-high 25 points and shot 7 of 8 on 3-pointers for the Badgers (16-5, 6-3). He was 9 for 14 overall, but his teammates went 11 for 36 from the field.
Wisconsin's guard trio of Hughes, Jordan Taylor and Jason Bohannon combined for 57 points in a home victory over Purdue earlier this month. The Boilermakers held them to 25 points on 8-for-28 shooting this time.
Moore scored in the lane with 25.2 seconds left to give Purdue a 58-57 lead.
Wisconsin worked the clock down for a shot and Hughes missed badly on a pull-up jumper, but the ball bounced out of bounds off a Purdue player with 6 seconds to play.
Hughes then missed a bank shot after Johnson and Hummel rotated over, and Johnson rebounded. Johnson was fouled with 1 second left, and made both free throws. Chris Kramer intercepted Wisconsin's long inbounds pass from under its basket to seal the win.
Purdue point guard Lewis Jackson played for first time this season. Jackson, who started as a freshman last season, injured his left foot during the preseason.
There were four lead changes in the first half, and neither team led by more than four points. A driving bank shot by Moore in the closing seconds of the first half put the Boilermakers up 27-25 at the break.
Wisconsin held Purdue scoreless for the first 5:44 of the second half to take a 34-27 lead.
The Boilermakers rallied quickly. A putback tip and a 3-pointer by reserve John Hart, then two free throws by Hummel tied the score at 38 with 11 minutes left. Moore's layup gave the lead back to Purdue and prompted Wisconsin to call timeout.
The Boilermakers pushed the lead to 56-49 before Wisconsin started chipping away. A 3-pointer by Nankivil cut it to 56-52, then a steal and layup by Taylor made it a two-point game.
Another 3 by Nankivil with 42 seconds left gave Wisconsin a 57-56 lead and set up the frantic ending.
(This version SUBS 12th graf to CORRECT that it was not Purdue's first lead of the second half)