Gray had 17 points and 10 rebounds to help the No. 13 Tar Heels beat the No. 8 Terrapins 73-70, sending UNC to the semifinals once again and setting up another date with its fiercest rival.
Rookie Diamond DeShields scored 22 points to lead the sixth-seeded Tar Heels (24-8), who led all but 5 seconds but still had to fight to put away the Big Ten-bound Terrapins in what turned out to be their final ACC game.
Now UNC is back in the semifinals for the 28th time in 37 tournaments with a chance at a three-game season sweep of No. 10 Duke on Saturday.
Gray, a 6-foot freshman, didn't play in the second half of Thursday's second-round win against Wake Forest after she hit her head on the court while being fouled shortly before halftime. She got off to a slow start Friday night, but provided the perfect complementary scoring punch to DeShields' latest big game.
"She's a tough, tough young lady _ very mentally tough," UNC associate head coach Andrew Calder said. "And we expected her to play tonight."
Gray said she sat out the second half Thursday "to be on the safe side."
"I woke up, no problems, no headache, no nothing," Gray said. "I was ready to go."
Gray was credited with a block on three-time ACC player of the year Alyssa Thomas' shot for the lead with 1:13 left, helping the Tar Heels hold on despite blowing nearly all of a nine-point lead in the final 5½ minutes and missing their last 10 shots.
Along the way, she finished 6 for 12 from the field, hit two 3-pointers, scored in the post and off of offensive rebounds.
"I knew when she got that extra rest time yesterday that she was going to be really fresh," Maryland coach Brenda Frese said. "I think Allisha is just a tremendous player. She does so many things. She has a really high IQ. ... She's just a really difficult matchup for us."
Thomas scored 24 points and set the career scoring record for third-seeded Maryland (24-6), but she couldn't quite lead the Terps all the way back on a night when her team was fighting uphill from the tip.
Maryland closed UNC's lead with back-to-back of baskets from Lexie Brown before Thomas hit a pullup jumper to make it 71-70 with 1:35 left.
But going 1-on-1 against Xylina McDaniel in the final minute, Thomas bobbled the dribble near the foul line and lost the ball, with a tie-up during a scramble giving the jump ball to North Carolina with 17.8 seconds left.
Brittany Rountree hit two free throws with 16 seconds left to push the margin back to three, then Thomas missed a straightaway 3 for the tie in the final seconds. Brionna Jones got the rebound and was fouled with 2.5 seconds left, but she missed the first free throw to set up an intentional miss on the second that UNC's Danielle Butts rebounded to seal the win.
Maryland fans knew this would be its last trip to the Greensboro Coliseum before the school's Big Ten departure in July. Before the game, several Terrapins fans held up a sign that read "Thank you Greensboro," where they won the 2009 and 2012 ACC tournament titles under Frese.
It ended up being a one-and-done farewell.
"Obviously, sad for it to be over," Frese said. "Definitely wanted to be able to go further. But just great memories. Obviously, great battles. When you talk about come tournament time and coming down here to Greensboro, they do a first-class tournament. So just a lot of special memories will be taken away."
Maryland shot 44 percent but committed 14 first-half turnovers that helped the Tar Heels take a 37-26 halftime lead. The Terrapins also missed 11 of 12 3-pointers.
Thomas finished with 11 rebounds but also had eight turnovers. The 6-2 senior hit a pullup jumper at the 11:19 mark to pass Crystal Langhorne's program record of 2,247 career points and needs 12 more to pass Juan Dixon for the school record by any player.
"Just a huge honor," Thomas said. "But we didn't come up with the win tonight so it's something I'm not really thinking about."