Peter Jok scored 29 points with eight assists and six rebounds for Iowa.
''When you go through what we went through down there, you have to learn from it,'' Iowa coach Fran McCaffery said of his young team's 89-67 loss on Dec. 28. ''You grow, and you figure it out.''
Freshman Tyler Cook had 16 points for the Hawkeyes (11-7, 3-2), who beat a ranked team at home for the second time this season.
''(Jok) made some tough shots. Maybe not for him, but tough for everyone else,'' Purdue coach Matt Painter said of Jok, who was 11 of 19 from the field. ''I thought we executed. We just didn't finish.''
Swanigan missed a layup in front of the rim with 13.8 seconds left and the Boilermakers down 79-78. Cordell Pemsl missed a subsequent free throw, but Iowa got the ball back after a lengthy review and Jordan Bohannon hit two from the line.
Dakota Mathias missed a contested 3 with 4 seconds left for Purdue, which lost for the first time this season to a team not in this week's Top 25.
''We got good looks. We didn't execute, and we put ourselves in a tough position,'' Painter said of the Boilermakers down the stretch.
One of the most entertaining sequences of this entertaining matchup came midway through the second half. Bohannon hit a 3 to give Iowa the lead. Ryan Cline answered with a 3 - and Bohannon went right down the court and buried another one. Cline answered back with another 3, the fourth between the two in just 62 seconds. That was indicative of a game with 20 lead changes.
Purdue has the weekend off before hosting Illinois on Tuesday.
Iowa will play at Northwestern on Sunday.