The Cornhuskers (11-10, 2-6 Big Ten) won for the first time in four conference home games.
Brandon Ubel had 14 points and 12 rebounds, and Gallegos added 11 points.
Ubel made two free throws and converted Gallegos' pass through the lane into a dunk at the front end of a 16-7 spurt that gave Nebraska a double-digit lead in the middle of the second half. Gallegos followed Shavon Shields' three-point play with three straight 3s to make it 44-33.
adidas Men's Nebraska Cornhuskers Fired Up Scarlet Performance T-ShirtPrice: $21.99 Shop
Maryland point guard Melo Trimble, considered a lock to leave the program before struggling in the second half last season, has withdrawn from the NBA draft and will return for his junior season.
Louisville's Chinanu Onuaku, who recently underwent a medical procedure to correct a heart rhythm issue detected during the combine, will keep his name in the NBA draft pool.
Andrew White III will return to the Nebraska men's basketball team next season after removing his name from the NBA draft.