CHAPEL HILL, N.C. (AP) -- Bambale Osby dropped to the court with his hands covering his face. He knew his basket had given Maryland the lead late. He heard the horn as North Carolina's final desperation shot clanged off the rim.
Yet he still couldn't believe it.
"It didn't feel real, man," Osby said. "It was like, 'Did this really just happen?' "
The same could be said of the top-ranked -- and formerly unbeaten -- Tar Heels.
Osby's layup with 21 seconds left helped Maryland stun North Carolina 82-80 on Saturday, giving the Terrapins a shocking win that will likely end the Tar Heels' run atop the polls.
James Gist finished with 22 points and 13 rebounds for the Terrapins (12-7, 2-2 Atlantic Coast Conference), who blew an 11-point lead midway through the second half but still held on in a back-and-forth finish to win here for the first time in five years.
Maryland hardly seemed the ideal candidate to stand up to North Carolina at the Smith Center. This was, after all, the same team that lost at home to Ohio and American in consecutive games in December. And the Tar Heels (18-1, 3-1) -- off to their best start in two decades -- had been rolling to big victories behind their crowd-pleasing and fast-paced transition attack.
But the Terrapins played tough and physical defense on Tyler Hansbrough, cutting off the All-American and making the Tar Heels work hard elsewhere for good looks in a largely halfcourt game. Maryland also showed the fortitude to bounce back after North Carolina pushed ahead by four in the final 2 1/2 minutes.
"I think our players really believed that if we could execute really good on offense, we had a chance to win the game," Maryland coach Gary Williams said.
The Tar Heels certainly had proven they could win the close ones, from Wayne Ellington's last-second 3-pointer in a 90-88 overtime win at Clemson two weeks ago to Wednesday's 83-82 win at Georgia Tech. But this time, they couldn't take advantage of several chances to answer Osby's layup.
After Ellington missed a 3-pointer and a driving shot, North Carolina could only watch as Hansbrough's last gasp 3-pointer bounced off the rim at the horn as the Terrapins ran to midcourt to celebrate.
Hansbrough had 17 points and 14 rebounds to lead North Carolina, which shot just 38 percent and went 7-for-23 from 3-point range. The Tar Heels were off to their best start since winning 21 in a row in the 1985-86 season, and came in averaging 98 points per game at home.
But on this day, North Carolina never led by more than four points.
"I haven't done a very good job with this basketball team the last couple of weeks," North Carolina coach Roy Williams said. "We've been living on the edge, and it caught up with us today."
The Tar Heels fought back from a 52-41 deficit midway through the second half to take a 78-74 lead on a three-point play by Danny Green with 2 1/2 minutes left. But Greivis Vasquez answered with a runner in the lane followed by two free throws to tie it at 78.
Then -- after two free throws by Gist and a basket by Hansbrough -- the 6-foot-8, 250-pound Osby found himself guarded by the 6-5 Green inside on a switch. Gist sent the ball to Osby, who spun away from an off-balance Green as he fell down and dropped it in for the 82-80 lead.
The Terrapins' defense -- the stingiest in the ACC for field goal percentage -- helped them hang on in the final frantic seconds.
"When the red light came on and the clock said zero-zero-zero, that's a feeling I'm not going to forget," Gist said. "I felt like we could win this game, but I never realized how it would feel."
Landon Milbourne finished with 14 points for Maryland, while Vasquez had 12 points and 11 assists. Osby finished with 12 points and five rebounds while matching up much of the way with Hansbrough.
Hansbrough went just 6-for-15 from the field while constantly finding himself surrounded by red jerseys, perhaps best illustrated when he had to go up amid three defenders to score in the paint and tie it at 80 with 51 seconds left. North Carolina managed only one significant offensive flurry, scoring 18 points over 4 1/2 minutes to erase the big deficit and tie it at 59 on Hansbrough's jumper with 10:56 left.
From there, the teams traded baskets in a finish that saw eight lead changes before Osby's layup put Maryland ahead for good.
"We're all just disappointed," said Ellington, who had 14 points. "We know we're better than that and we have a lot of work to do."
Former Kentucky guard Ed Davender, the only Wildcat with at least 1,500 points and 400 assists, has died. He was 49.
Guard Naz Mitrou-Long, whose 2015-16 season ended in December due to hip problems, has been granted a hardship waiver for the coming season, Iowa State said.
As the Sooners look to life without superstar Buddy Hield and his sidekicks, it's clear their unseasoned players will need to grow up fast.