WEST LAFAYETTE, Ind. (AP) — In the minutes leading up to the start of Saturday's Top 25 showdown with No. 10 Maryland in Mackey Arena, No. 20 Purdue's senior center A.J. Hammons pulled sophomore guard Dakota Mathias aside for a conversation.

"I gave him a pep talk," Hammons said, "I told him, "Shoot it, don't pass it." That allowed me to get great position inside."

Hammons scored 19 points, and Mathias added a career-best-tying 17 to lead five Purdue players in double figures, and the Boilermakers held on for an 83-79 victory over Maryland.

Purdue (22-7, 10-6 Big Ten) guard Rapheal Davis and forward Vince Edwards each scored 11 and Caleb Swanigan had 10 in Purdue's second victory over a Top 10 opponent in 18 days.

The Boilermakers defeated No. 6 Michigan State on Feb. 9. It is also Purdue's school record-tying 16th home victory this season.

In what has sometimes been a frustrating season, the Boilermakers have been seeking a balance between interior and perimeter scoring. Against Maryland, Purdue finally got it when 7-footer Hammons and shooting guard Mathias combined to make 14 of 20 field goal attempts, including 5 of 8 from 3-point range.

"Obviously, Dakota played very well," Purdue coach Matt Painter said. "He was playing well enough today that we wanted to keep him in there. He and A.J. kept it simple and just made plays. When we don't get ahead of ourselves, we are pretty good.

"We got a little passive with our guard play, which allowed Maryland to get back in the game. We had played so well to build a double-digit lead. This was a big win against a very good Top 10 team."

Overall, the Boilermakers shot 51.7 percent (31 of 60) and out rebounded the Terrapins, 41-22.

"I made shots, and that helped open things up for A.J.," Mathias said. "Thus far, this was my No. 1 performance of my career. We played so well, and then we had a rough stretch. Had we lost this one, it would have been devastating."

But Purdue did not let this one slip away.

"The difference in the game was that we couldn't rebound the ball, and they could," Maryland coach Mark Turgeon said. "I thought our first-shot defense was good enough to win the game."

Purdue, however, had 19 offensive rebounds and enjoyed a 24-10 advantage in second-chance points.

Hammons made a free throw with 1:49 to go to break a 76-76 tie, and a layup by Johnny Hill made it 79-76 with 1:16to go.

Davis and Edwards each made two free throws in the final 23.1 seconds to help the Boilermakers withstand a late charge from Maryland (23-6, 11-5).

Melo Trimble led the Terrapins with 19 points, Diamond Stone scored 18 and Jake Layman added 15.

The Terrapins used a 12-2 run to tie it at 76 on a layup by Layman at the 2:12 mark. That 12-2 burst was fueled by five Purdue turnovers in 2 minutes after building a 10-point lead.

"We rebounded the ball well all night, and that saved us," said Davis, who had seven rebounds from a guard position. "I was aggressive all game, and I wanted to stay aggressive. Everybody contributed today. They made Papa Bear (Davis) happy."

A 9-3 burst helped Maryland cut the Purdue lead to 58-56 with 10:36 to play, but Swanigan hit a 3-pointer and a layup off a perfect pass from Mathias to push the lead to 63-56 with9:49 left.

Purdue extended its lead to 71-62 with 6:02 left on a putback by Hammons and to 74-64 on a 3 by Hammons with4:13 remaining.

With Mathias making five consecutive shots and scoring 12 first-half points, the Boilermakers led 44-39 through 20 minutes, during which they shot 57.6 percent from the field (19 of 33). Purdue outrebounded the Terrapins 21-9 in the first half.

TIP-INS:

Maryland: The Terrapins entered the game ranked first in blocked shots, second in scoring defense, field goal percentage and 3-point field goal percentage defense during Big Ten Conference games. ... In the past two seasons, the Terrapins are 20-3 in games decided by six points or less, which is the best among Division I teams.

Purdue: Since losing to Maryland on Jan. 10, 2015, the Boilermakers entered 21-1 in Mackey Arena, losing only to Iowa on Jan. 2, 2016. ... Before playing the Terrapins, Purdue had been outscored by 70 points as the result of turnovers in its seven defeats, losing those contests by a collective 59 points. ... The Boilermakers have won at least 20 games in eight of coach Matt Painter's 11 seasons at his alma mater.

UP NEXT:

Maryland: Hosts Illinois on Thursday.

Purdue: Travels to Nebraska on Tuesday.