Russell Wilson threw four touchdown passes and Alan-Michael Cash blocked a field goal with about 5 minutes left to help North Carolina State rally past No. 23 North Carolina 28-27 on Saturday.

Wilson connected twice with Owen Spencer for scores, including the go-ahead 38-yard touchdown two plays into the fourth quarter that gave the Wolfpack (5-7, 2-6 ACC) a third straight win against its next-door neighbors and fiercest football rival.

T.J. Yates threw two touchdown passes to Jheranie Boyd for the Tar Heels (8-4, 4-4), while Johnny White scored on a 40-yard run that helped North Carolina take a 10-point halftime lead.

But the Tar Heels repeatedly cost themselves with penalties and a goal-line fumble that wiped out what should have been a short TD run in the first quarter.

Wilson and the Wolfpack offense got off to a sluggish start against a defense that has ranked among the nation's toughest all year. But the longer the game wore on, the better Wilson and his teammates got, until Wilson put N.C. State on top by lofting a pass over the middle to Spencer, who sprinted away from defender Da'Norris Searcy for the 28-27 lead with 14:31 to play.

The win capped an emotional week _ and morale-draining season _ for the Wolfpack, who learned earlier this week that offensive coordinator Dana Bible had been diagnosed with leukemia and would not be with the team Saturday. N.C. State figured it was in position to contend for an ACC division title with Wilson and a schedule that included eight home games, but the Wolfpack lost six of seven coming in to see their bowl hopes slip away.

Yet N.C. State is savoring another win against the Tar Heels.

It has won all three meetings under Tom O'Brien against Butch Davis' Tar Heels, giving them another year to chew on a frustrating loss that seemed to be going their way early on.

Wilson completed 20 of 27 passes for 259 yards, including a critical third-down strike to Spencer with about 3 minutes left that moved the chains and allowed the Wolfpack to work on the clock while the Tar Heels _ who burned their final timeout with 3:16 left _ could do nothing to stop them.

North Carolina finally got the ball back at its own 28-yard line after a fourth-down stop with 23 seconds left. Yates forced a pass to Erik Highsmith, but the throw went high and into the arms of Clem Johnson to seal the win.

Perhaps the Wolfpack's biggest stop came earlier in the period with the Tar Heels driving for the go-ahead score. N.C. State strung out an end-around from Boyd for a 12-yard loss to force the Tar Heels into a 38-yard field goal attempt for the lead, and Cash blocked the low kick with 4:44 to play.