CHAPEL HILL, N.C. -- Roy Williams kept screaming for his North Carolina team to play tougher and smarter, even ripping off his jacket at one point to drive home his message.

His fifth-ranked Tar Heels responded, even as they were locked in a possession-to-possession game with a top 10 opponent less than a week after their first loss that knocked them from No. 1.

Harrison Barnes scored 10 of his 20 points during the decisive second-half surge to help North Carolina rally past Wisconsin (No. 7 ESPN/USA Today, No. 9 AP) 60-57 on Wednesday night, a victory that came only after the Tar Heels strung together enough defensive stops and got enough rebounds to aid their struggling offense.

Tyler Zeller added 12 points for the Tar Heels (6-1), who had to show the fight and toughness they didn't show in last weekend's upset loss to UNLV to outlast the Badgers (6-1) in the ACC/Big Ten Challenge. With its fast-paced attack unable to get out in transition, North Carolina trailed by five points midway through the second half before going on an 18-5 run that finally put the Tar Heels ahead for good.

It was tense enough all night that Williams said he told Wisconsin coach Bo Ryan afterward, "I'm glad I don't play you anymore."

"That's the type of games you're going to end up having to deal with," said UNC junior John Henson, who had 17 rebounds and five blocks. "I'm glad we had one early on in the season. There's going to be more and hopefully we're going to be ready."

For the Badgers, almost everything went to plan except for the outcome.

They made the Tar Heels work for their shots. They repeatedly made them defend into the final seconds of the shot clock. But North Carolina -- which despite the NBA potential on its front line had been outrebounded three times this season -- responded by controlling the boards behind Henson, finishing with a 42-29 advantage against a team that had outrebounded opponents by an average of 14 per game.

The Badgers came in holding teams to 39 points and 31 percent shooting, and they held the Tar Heels to 42 percent in this one. That included a 6-minute scoreless stretch in the first half, but the Badgers didn't fare any better (36 percent) and couldn't knock down the 3-point shots that would have brought even more stress to the blue-clad crowd.

Wisconsin, which was shooting 47 percent from 3-point range, missed 20 of 28 shots from behind the arc.

In a sign of how well Wisconsin played -- other than making shots, of course -- the Badgers finished with just four turnovers despite the Tar Heels chasing them in man defense all night.

"We've got a confident group, no matter what," said Jordan Taylor, who had 18 points to lead Wisconsin. "That was a game we wanted to win. I don't believe in moral victories. It's frustrating. They're a good team. Hats off to them. They made plays and we didn't down the stretch."

Barnes was critical in the run, knocking down two 3-pointers and a jumper despite being hobbled by a sprained right ankle from the loss to the Runnin' Rebels. He played 30 minutes in that game, but missed Monday's practice and Williams didn't sound sure Barnes would be ready for the Badgers. But Barnes made it through a full practice Tuesday evening and was back in the starting lineup to provide just enough of a spark to the Tar Heels' bogged-down offense.

"You just have to make quick decisions," Barnes said. "The defensive team that Wisconsin is, they load up very quickly off the catch. So you knew you had to make a quick decision when you got the ball or make the quick pass."

North Carolina also shook off its struggles at the foul line by hitting 16 of 18 free throws in the second half. Yet even after the Tar Heels pushed ahead by 10 with about a minute left, Wisconsin didn't go away and ended the game with Ben Brust making a heave from near halfcourt at the buzzer. The shot capped what Ryan called "as hard-fought a game as I have ever been in as a coach."

"We were right there," Taylor said. "I'd love to see those guys again, maybe in the tournament or something like that. We welcome the challenge."

Things won't get easier for UNC. Next up is Saturday's trip to Kentucky, which replaced North Carolina at No. 1.

The Tar Heels played much of the second half without freshman guard P.J. Hairston, who headed to the locker room with about 12 minutes left after hurting his left wrist during a fall.