CHAPEL HILL, N.C. -- North Carolina bumbled its way to three losses in November and had an ugly loss to one of the Atlantic Coast Conference's worst teams in January.

That team is long gone, replaced by a maturing group that enters the final week of the regular season within reach of an ACC championship.

Tyler Zeller scored 25 points while freshman Harrison Barnes had 21 to help the 19th-ranked Tar Heels beat Maryland 87-76 on Sunday night, pulling them into a tie with Duke atop the league.

Leslie McDonald added 15 points off the bench to break out of a slump for the Tar Heels (22-6, 12-2), who led the entire night for their 15th win in 17 games. Now, a year after a 17-loss season, the Tar Heels travel to Florida State -- sitting in third in the league -- on Wednesday night before hosting the reigning national champion Blue Devils on Saturday night in a game that could determine the top seed in the ACC tournament.

"At the beginning of the season, Coach [Roy Williams] said we had big goals and dreams that are realistic," sophomore John Henson said. "It might have been hard to believe at that time, but now it's a reality and we have to keep it going."

Duke's loss at Virginia Tech gave the Tar Heels the chance to finally catch up after hovering just behind the Blue Devils since a 79-73 loss at Cameron Indoor Stadium earlier this month.

It seemed unlikely for a team that looked unsure during early losses to Minnesota, Vanderbilt and Illinois. Or the one that lost by 20 points to a Georgia Tech team that has just three ACC wins. But the Tar Heels have played defense well enough to keep their Hall of Fame coach happy and grown steadily more efficient on offense.

"We've been working all season to make sure we get to this position," Barnes said. "And it's been a struggle. We definitely had times where we didn't think we could do it. But now we're in this position and we just have to seize the moment."

Williams wasn't interested in dwelling on the ACC regular-season crown just yet.

"It would mean a great deal," he said, "but we better be thinking in terms of Florida State and not be thinking about Duke."

The Terrapins (18-11, 7-7) could've used this win to bolster their NCAA tournament hopes. But while freshman Terrell Stoglin (season-high 28 points) and Jordan Williams (career-high 19 rebounds) turned in strong performances, they got almost no help from their teammates. The rest of the Terrapins combined for 32 points on 11-for-37 shooting.

The Tar Heels outscored the Terrapins 23-6 in the stretches when Williams came out of the game, leading by a dozen at halftime and pushing that lead to as many as 17 midway through the second half.

"Early on, I felt it wasn't one of our better starts in terms of our effort, just being aware and being alive," Maryland coach Gary Williams said. "Once you get behind like that, it's really hard to burn that much energy to keep the game in striking distance, then try to make a comeback."

Maryland closed within seven points before the Tar Heels ran off a 14-4 spurt, which included Marshall saving a ball by throwing it between Zeller's legs to Dexter Strickland, who found Barnes ahead for a layup midway through the second half.

Then, after jumpers from Barnes and Justin Knox, Zeller capped the run with a hook shot over Williams, followed by a transition layup off a perfect pass from Marshall to make it 68-51 with 10:35 left.

Meanwhile, the Terrapins went cold at just the wrong time, going more than 4 minutes without a basket and committing a pair of turnovers that the Tar Heels converted into scores.

Maryland got no closer than eight points the rest of the night.

Zeller made 10 of 16 shots while joining with Henson (10 points, 15 rebounds, seven blocks) to keep plenty of pressure on Williams inside. The Tar Heels also got strong floor games from their starting backcourt of Marshall (10 assists, six rebounds) and Strickland (career-best eight assists).

McDonald's emergence certainly helped, too. He hit three 3-pointers and had as many field goals in this game (six) as he had in the past four games combined.