TALLAHASSEE, Fla. -- 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's 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.