Trimble hit a 3-pointer from the left corner with 2:03 remaining for a 60-55 lead before Marc Loving made a pair of foul shots for Ohio State to trim the lead to three.
Maryland's Robert Carter, who had 10 points, then made both shots from the line with 24.4 seconds left. JaQuan Lyle made 1 of 2 foul shots for OSU to cut the deficit to 62-58 but Rasheed Sulaimon hit two free throws for Maryland (19-3, 8-2 Big Ten) with 13.5 seconds to go.
Jae'Sean Tate, who had 16 points for Ohio State (14-9, 6-4), made a 3-pointer with 5.9 to go but Trimble was fouled and made two more foul shots with 5.4 remaining to seal the win.
Ohio State, who lost to the Terrapins by 35 points earlier this month, went ahead 51-50 on Kam Williams' jumper with 6 minutes but Trimble hit two foul shots to regain the Maryland lead.
The Terrapins couldn't extend their more than four over the next few minutes before Trimble's 3-pointer.
Maryland withstood everything Ohio State had to offer and took a 37-31 lead into halftime after trailing by seven less than eight minutes into the game.