Kendall Stephens had 14 points, including four 3-pointers, and Ronnie Johnson had 11 points for the Boilermakers (14-9, 4-6 Big Ten), who snapped a season-worst four-game skid.
Maurice Walker had 17 points and six rebounds and DeAndre Mathieu added 15 points for the Golden Gophers (15-8, 4-6), who have lost three straight.
Minnesota was called for a shot-clock violation and Hammons scored a lay-up with 57 seconds left to put the Boilermakers ahead 75-74.
Johnson made a free throw with 18 seconds left to make it 76-74. Errick Peck grabbed the rebound, was fouled and scored a free throw to give Purdue a 77-74 lead.
It wasn't easy for either team. Purdue and Minnesota hit enough shots to keep playing, but couldn't score to put the game away until the Boilermakers went to the line late in the third overtime period.
Hammons scored a pair of free throws with 31 seconds left in regulation to give the Boilermakers 60-58 advantage. Terone Johnson missed two free throws with four seconds remaining and a chance to extend the lead for Purdue.
Austin Hollins scored at the buzzer to tie the game a 60 to force overtime.
Then, in the first overtime period, Hammons scored two more free throws at the start and Ronnie Johnson scored to give Purdue a 64-60 lead.
Minnesota missed three shots and turned the ball over before Mathieu scored two free throws with 59 seconds left to make it 64-62.
Hammons was called for a foul on a rebound that sent Mathieu back to the line. He scored a pair of free throws to tie the game at 64 to force a second overtime period.
Hammons got things going in the second overtime period, too. He was fouled on a shot at the 4:00, but missed the free throw and Purdue took a 66-64 lead.
Walker scored a lay-up to tie the game, but Terone Johnson gave Purdue the lead again on a put-back layup to give Purdue a 68-66 advantage.
Walker tied the game again with under three minutes to play and neither team scored the rest of the overtime period.
Then in the third overtime period, Mathieu scored with 2:15 remaining to give the Golden Gophers a 74-73 lead.
Terone Johnson missed a shot, but grabbed his own rebound before he was fouled with 1:53 left. He missed both free throws and Minnesota took possession to the sound of boos from Purdue fans.
It didn't last long.
Minnesota was called for a shot clock violation and Hammons scored a lay-up with 57 seconds left to put the Boilermakers ahead 75-74.
Minnesota's Andre Hollins played for the first time since suffering an ankle injury in a victory against Wisconsin on Jan. 22. The Golden Gophers lost the two games the team's leading scorer missed. He finished with eight points.