Updated

T.J Yates' record-setting performance delivered North Carolina a victory in a place it had never won before.

Yates threw for a school-record 439 yards, Casey Barth kicked his third goal, a 22-yarder, with 55 seconds left and the Tar Heels beat No. 24 Florida State 37-35 for their first victory in nine games in Tallahassee.

Florida State kicker Dustin Hopkins missed two field goals in the fourth quarter, including a 40-yard try with 7 seconds left.

Yates threw three touchdown passes and took the Tar Heels 72 yards on the winning drive to set up Barth's decisive kick. Yates' 31-yard completion to Dwight Jones was the big play in a drive that North Carolina coach Butch Davis called the best one in his four years at the school.

"Tonight was kind of somewhat to be honest with you a microcosm of the whole season," North Carolina Davis said. "It seems like every week there's drama and adversity, challenges."

In a season in which the Tar Heels (6-3, 3-2) were expected to contend for the ACC championship they have dealt the loss of several star players because of a pair of NCAA investigations.

Still, they have salvaged the season by becoming bowl eligible and beating Florida State for only the second time in 18 meetings.

The loss was new coach Jimbo Fisher's first at home since replacing the iconic Bobby Bowden earlier this year. And it was the second straight game Florida State let a last minute opportunity for a win slip away.

"There's ups, there's downs," Fisher said. "We have to learn to not let it come down to a final play."

The Seminoles (6-3, 4-2 Atlantic Coast Conference) lost control of their own destiny in the league race after a 28-24 defeat at North Carolina State on Oct. 18, when Ponder fumbled the ball inside the Wolfpack 5 in the waning seconds of the game.

Florida State once again was in position to regain an inside track for the Atlantic Division berth in the ACC's title game since Maryland and N.C. State both lost earlier in the day.

Instead, the division will be a scramble to the finish — much like this game.

Florida State took a 35-34 lead with 5:49 left on Lonnie Pryor's second touchdown, which was set up by a botched North Carolina snap. The Seminoles got the ball at the North Carolina 1 after Mark House's snap sailed over the head of punter C.J. Feagles, who then illegally kicked the ball out of the end zone.

While Barth was thrilled about producing the game-winning points, he felt for Hopkins.

"I've been there and missed a field goal to the right," Barth said. "It's the worst feeling in the world."

Yates' yards passing were the most against Florida State since Florida's Danny Wuerffel passed for 443 yards in a 1995 Gator victory.

"We knew we were going to have matchups underneath," said Yates, who broke his own school mark of 412 yards passing earlier this year against LSU. "We were kind of on a hot streak."

Florida State's secondary had no answers for the 6-foot-4, 220-pound Jones, who caught eight passes for 233 yards, one on 67-yard touchdown from Yates that made it 14-7 UNC with 2:39 left in the opening quarter.

Both Jones and Yates said they weren't picking on the 5-foot-8 cornerback Greg Reid.

"We watched a lot of film," Jones said. "We weren't planning on going on him because of his size."

North Carolina trailed 28-21 at the half.

The early part of the game shaped up as a duel between Yates and Florida State's Christian Ponder. The two fifth-year seniors combined to throw for 422 yards and five touchdowns by halftime.

But Yates kept it up in the second half, while Florida State's offense nearly disappeared.

Yates started fast, completing a 38-yard throw to Jones on the game's first play to ignite a 60-yard scoring drive culminated by a 6-yard TD run by Johnny White, who was knocked out of the game moments later with a shoulder injury.

Jermaine Thomas' 18-yard run set up a 5-yard touchdown pass from Ponder to Willie Haulstead as Florida State tied it midway through the first period.

Ponder's 27-yard touchdown throw to Rodney Smith tied the game at 14 and Taiwan Easterling scooted 7 yards with a short pass from Ponder to give the Seminoles a short-lived 21-14 lead.

Yates countered with a 14-yard scoring pass to Anthony Elzy.

Ponder completed 24 of 34 passes for 264 yards and three touchdowns and Haulstead had a career game with 10 catches for 154 yards.

But the Seminoles couldn't get their offense restarted in the second half for a third straight week.

"The offense really sputtered," Ponder said. "We didn't play well at all."