"He just needs to stay calm and be Melo," Turgeon said.
With the game tied at 73, Trimble fed guard Dez Wells for a go-ahead jumper in the lane.
"Melo's a winner, and he does whatever he has to do to win the game," Turgeon said. "We were going to Dez. I told the whole team. I told the staff. We were creating plays at the timeouts, drawing them up in the dirt. It worked. He hit a big-time shot in the lane. That's not an easy shot."
Wells finished with 14 points but was quick to credit his freshman teammate.
"I knew he would keep his cool," he said. "He makes it easy for everyone else when you have a point guard who is so poised."
Trimble was 7-for-11 from the field and made four of six from 3-point range. He also converted 13 of 14 free throws for the Terps (4-0).
The key for Maryland was controlling the paint. The Terrapins outrebounded the Sun Devils 34-24 and kept them from scoring much inside. The Sun Devils were left to shoot from the outside, which they did exceptionally well. They were 14-for-27 from beyond the 3-point line.
But with the game on the line, Turgeon was glad Trimble had the ball in his hands.
"I've been watching Melo for four years, and he is who he is," he said. "He made his first one. It kind of hit the rim and rolled in. I knew it was going to be his night.
"He got to the foul line, which he's good at doing. He's very composed; our whole team was. It's hard when teams are [hitting] 3s like that."
Arizona State did not leave disappointed.
"Obviously, we didn't play perfect basketball, but I think our team played pretty good basketball," Sun Devils coach Herb Sendek said. "I thought both teams, for as early as it is in the season, played some good offensive basketball.
Trimble "had a terrific game. He had 31 points, and did a good job with the middle screen. I think he's an elite shooter."
The second half was much closer than the first. Neither team led by more than five points in the final 20 minutes.
Arizona State was hampered by poor free-throw shooting in the second half, when the Sun Devils went just 4-for-9. Midway through the second half, Gilling and Barnes hit consecutive 3-pointers to erase a four-point deficit.
Maryland started slowly, going scoreless in the first four minutes before Trimble put the Terps on the board with a 3-pointer to cut the margin to 7-3. The Sun Devils led by as many as seven points on several occasions.
"I thought Arizona State was terrific," Turgeon said. "They were ready to play and we weren't. They were more physical at the start."
But led by Trimble, who hit two at the free-throw line with just over six minutes left in the first half to tie the score for the first time at 31, the tide turned. The free throws gave Trimble 16 points, three more than his previous season high, set against Wagner in his college debut.
A 3-pointer by guard Bo Barnes gave Arizona State the lead again, before forward Jake Layman hit a pair of free throws and Trimble made a layup to give the Terps their first and only lead of the half.
Barnes hit another 3, followed by a runner across the lane by Layman to tie it at 37. Guard Tra Holder scored inside just before the buzzer to give Arizona State a 39-37 lead at the half.
NOTES: Maryland coach Mark Turgeon returned to his home area for the game. Turgeon grew up about an hour west of Kansas City in Topeka, Kansas. He played collegiately at Kansas, which is less than an hour away. Turgeon expected about 50 family and friends to be in attendance. ... Arizona State had not allowed any opponent to score more than 50 points in the first three games.