After Wells made two free throws, Trimble beat the shot clock with a jump shot from atop the key. The freshman guard connected again from beyond the arc with 2:18 remaining for a 62-54 lead.
That was just enough to provide Maryland with another close win. The Terrapins have won their last three games by a total of 11 points and are 8-0 in games decided by six points or fewer.
Trimble went seven-for-nine from the floor and made 10-of-11 free throws. He also led Maryland with six rebounds and five assists.
Walter Pitchford scored 19 and Shavon Shields added 13 for Nebraska (13-13, 5-9). Terran Petteway, who came in averaging 18.7 points, was held to eight on 2-for-14 shooting.
A three-pointer by Pitchford got the Huskers to 65-62 with 29 seconds left, Nebraska gained possession on a steal. But Wells stole the ball and Trimble made two free throws on the other end to clinch it.
Maryland improved to 16-1 at home, 7-0 in the Big Ten.
"I'm proud of my guys. They figured it out and got it done," head coach Mark Turgeon said. "Melo [Trimble] was terrific down the stretch. You have to give Nebraska a lot of credit, they shot the ball really well.
"I thought we did a great job on [Terran] Petteway. Our game plan was to try to stop him, and I thought we did a pretty good job doing that. Considering the weather, I thought we had a great crowd tonight with everyone coming out and supporting us."
After Nebraska made the first two baskets of the second half to go up 38-34, Trimble hit a runner to spark a 10-0 run that put Maryland up by six.
A three-pointer by Jared Nickens made it 49-42 with 11:29 remaining, but the Huskers answered with a 6-0 spurt that included a pair of baskets by Leslee Smith.
Maryland led 50-48 when Petteway was called for his fourth foul with 8:05 left. Two straight field goals by Shields knotted the score at 52 with 6:59 to go, setting the stage for the exciting finish.
Trimble scored 11 points and Wells had 10 to stake Maryland to a 34-33 halftime lead.
Nebraska got 22 points from its bench, including 11 by Pitchford, to keep it close. Pitchford had started all 25 of the Huskers' previous games this season.
Maryland made six of its first seven shots, including two from beyond the arc, to take a 14-5 lead.
The Huskers trailed 32-21 before Petteway and Pitchford hit three-pointers to start an 11-2 run before the break.
Maryland returns to action when it hosts No. 5 Wisconsin on Tuesday at 7 p.m. at XFINITY Center.