RALEIGH, N.C.(AP) Even in a season gone awry, Russell Wilson and North Carolina State still know how to beat North Carolina.
Wilson threw four touchdown passes and Alan-Michael Cash blocked a field goal attempt with about 5 minutes left to help the Wolfpack rally past the 23rd-ranked Tar Heels 28-27 on Saturday, ending a bowl-less season in the jubilant style that only a win against a nationally ranked rival can bring.
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 their next-door neighbors and fiercest football rivals. All three have come since Tom O'Brien took over shortly after the Tar Heels (8-4, 4-4) made their big splash by luring former Miami and NFL coach Butch Davis to Chapel Hill in late 2006.
''It means a tremendous amount to this program,'' O'Brien said. ''They're going to ask how (their) senior year was, and they're going to say, 'We beat Carolina.' And that'll sum up their year.''
That should offer some solace to a program that expected it could contend for an ACC division title only to see everything go wrong. The defense was terrible all year, allowing 30 or more points in seven straight games to undermine an offense that returned an all-ACC quarterback in Wilson and averaged about 31 points.
Much of those troubles began with injuries, starting with losing top linebacker Nate Irving for the season after he was injured in an offseason car wreck. Another 11 players went down with season-ending injuries.
''Thank God it's over,'' O'Brien said. ''I mean, I don't think we could go play in a bowl game if we had to.''
While playing North Carolina in a de facto bowl game was incentive enough, the Wolfpack also had the motivation of playing for offensive coordinator Dana Bible. The team learned earlier this week that Bible, who was not with the team for its final two games, had been diagnosed with leukemia and would be hospitalized for treatment for a month.
Bible was clearly on Wilson's mind afterward. He chucked the football into the stands in celebration, then remembered he wanted to send it to Bible. So team staffers sought out the fan who had the ball and got it back, though O'Brien said he planned to send the fan another ball to replace it.
Wilson said he had spoken with Bible as recently as Friday.
''I felt it right here in my heart for him,'' Wilson said. ''He told me to persevere, he told me to keep my mind in the right spot, to play the game how I know to play the game.''
Wilson completed 20 of 27 passes for 259 yards, including a 25-yard pass to Spencer on third down 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 28-yard line after a fourth-down stop with 23 seconds left. T.J. Yates forced a pass to Erik Highsmith , and the throw went high and into the arms of Clem Johnson to seal the win.
Yates threw two touchdown passes to Jheranie Boyd for the Tar Heels , including a 70-yarder in the final minute of the first half, while Johnny White scored on a 40-yard run that helped North Carolina take a 24-14 halftime lead.
But the Tar Heels repeatedly cost themselves with penalties and a goal-line fumble by White that wiped out what should have been a first-quarter TD run.
In fact, the Tar Heels had two penalties after driving inside the 10 - one holding, one personal foul - that forced them to settle for field goals. Then there was a second-quarter touchdown drive by the Wolfpack in which North Carolina's defense was flagged twice for pass interference and once for roughing.
North Carolina was penalized 10 times for 122 yards in the game.
''It's very disappointing,'' Davis said. ''We didn't play very smart today.''
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. Then the Wolfpack's much-maligned defense earned its biggest stop of the game, stringing out an end-around from Boyd for a 12-yard loss that forced the Tar Heels into a 38-yard field goal attempt for the lead. Cash blocked the low kick with 4:44 to play.
''They just did a good job of stealing the momentum,'' North Carolina safety Deunta Williams said.