RALEIGH, N.C. (AP) Too often for No. 24 N.C. State, rival North Carolina has proven to be the thorn in its side - crashing the party in otherwise successful seasons or, more recently, outright embarrassing the Wolfpack in blowouts.

Friday night was shaping up to be more of the same, with North Carolina up 30-21 late and playing spoiler as N.C. State looked to keep hopes of an ACC Atlantic Division title alive. Two touchdowns in 26 seconds kept those hopes alive a little longer.

Devin Leary threw those two touchdown passes in that short span, with North Carolina State recovering an onside kick in between, to stun North Carolina 34-30.

Leary found Emeka Emezie on a busted coverage for a 64-yard touchdown strike with 1:33 left. The Wolfpack recovered the onside kick, then Leary threw a 24-yard sideline pass to Emezie with 1:09 remaining.

''What a football game,'' Wolfpack coach Dave Doeren said. ''What a game. That's why you play until the last second's off the clock.''

N.C. State (9-3, 6-2) beat North Carolina (6-6, 3-5) for the first time since 2018 to remain in contention for a trip to the conference championship game. It also officially eliminated six-time reigning league champion Clemson from the Atlantic Division race.

The Wolfpack would reach the title game if No. 21 Wake Forest loses at Boston College on Saturday, creating a three-way tie atop the division that would favor N.C. State by virtue of its division record and head-to-head win over Clemson.

Leary finished with 247 passing yards and four touchdowns.

Sam Howell had three total touchdowns for North Carolina, and running back British Brooks ran for 124 yards for North Carolina.

THE TAKEAWAY

N.C. State: The rivalry has rarely been about more than local pride, but the conference implications for the Wolfpack meant an added layer of intrigue for this 2021 iteration.

The Wolfpack jumped out to a 14-0 lead in the first quarter but looked dead for much of the night, managing just seven points in the second and third quarters; two touchdowns in 26 seconds changed all that.

North Carolina: The Tar Heels, bowl eligible as of last week, had nothing to play for Friday night except bragging rights - and the chance to play spoiler.

Though Howell, who missed last week's game against Wofford with an upper-body injury, seemed to be running for his life all night, he managed to run for two scores and keep drives alive with his legs.

A pair of late collapses, however - the busted coverage on Emezie, and the botched onside recovery - proved costly.

''I've never seen anything like it. I've got to do a better job,'' North Carolina coach Mack Brown said. ''We've still got work to do, and that comes back to me.''

UNLIKELY ONSIDE

Down two with 1:35 left, kicker Christopher Dunn kicked his onside attempt right down the middle of the field. The ball bounced up in the area of two Tar Heels, who both had a chance at it, but kept rolling until it was recovered by the Wolfpack's C.J. Riley. From there, a pair of 15-yard penalties - a roughing the passer and a pass interference - helped keep the Wolfpack drive alive before the game-winning toss to Emezie.

LEARY'S YEAR

Leary's four passing touchdowns put him at 35 on the season, passing Phillip Rivers' 34 for the highest single-season mark in Wolfpack history. He also leads all quarterbacks in touchdowns against ACC competition with 27.

His last score also gave the Wolfpack a perfect record at home this season, a first since 1986.

UP NEXT

N.C. State: The Wolfpack will be locked in on Wake Forest's noon matchup against Boston College, with a Demon Deacons loss sending N.C. State to its first ACC championship game.

North Carolina: Await bowl fate.

Copyright 2021 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.