COLUMBIA, S.C. (AP) For three quarters, Kyle Trask saw the overthrows and ineffective runs, the penalties and missed assignments. He knew something had to change.

It finally did.

Trask threw three of his career-high four touchdowns in the final period Saturday to rally the No. 9 Gators to a 38-27 win at South Carolina.

Trask, sensing the game slipping away, told his teammates: ''This isn't us.'' He then helped the Gators (7-1, 4-1 Southeastern Conference) avoid a second straight loss after falling at No. 2 LSU 42-28 last week.

''We found our identity and started making plays,'' he said.

This season, the identity of Florida's offense is very much in Trask's hands. The redshirt junior, starting because of an injury to Feleipe Franks, has led the Gators to their best start since 2015.

After a week off, Trask will bring Florida to a final, defining stretch with games against No. 10 Georgia, Vanderbilt and SEC East-leading Missouri in the chase for a spot in the SEC title game.

Things didn't look promising through the third quarter. South Carolina (3-4, 2-3) held Florida in check and took a 20-17 lead in trying for its second consecutive win over a top 10 opponent after beating then-No. 3 Georgia in double overtime last week.

''We have a very resilient team,'' Trask said. ''We're never going to panic, no matter the situation.''

That was evident in the second half.

After Trask's interception deep in Florida territory led to Tavien Feaster's 21-yard TD run to put the Gamecocks up 17-10, Dameon Pierce answered with a 75-yard scoring run on Florida's next snap to tie it.

In the final period, down 20-17, Trask faced fourth-and-3 on South Carolina's 34 before scrambling from pressure to pick up the first down with a 9-yard pass to Kyle Pitts. Trask followed with the go-ahead 25-yard touchdown throw to Lamical Perine.

Florida's defense also came through down the stretch after the Gators took the lead. Defensive end Zachary Carter sacked Ryan Hilinski, who fumbled as nose tackle Kyree Campbell recovered.

Florida linebacker David Reese said the players were intent on not letting the LSU loss affect them.

''We can't let one loss turn into another,'' he said.

Trask, who completed 21 of 33 passes for 200 yards, finished the series with a 5-yard TD pass to Pitts before a final scoring pass of 5 yards to Trevon Grimes.

South Carolina looked poised once more shuffle the SEC East race with an upset. But like a year ago, when Florida rallied from 31-14 down to defeat the Gamecocks 35-31, South Carolina could not hold.

''Get the lead in fourth quarter, got to make some plays. We didn't do that,'' South Carolina coach Will Muschamp said.

Hilinski, who sprained his knee in the Georgia win, was not sharp for most of this game. The freshman completed 17 of 35 throws for 170 yards.

''We've got to find a way to throw the ball better,'' he said.

Feaster, the Clemson graduate transfer, ran for 175 yards for South Carolina, which was outscored 21-7 in the final period.

THE TAKEAWAY

Florida: The Gators now have time to recover from injuries and recoup from a two-month stretch of football. Florida gets next week off before starting a run of three straight SEC East games.

South Carolina: The defense gave the team a chance at another stunner. But inconsistency on offense sent South Carolina to its fourth loss to Florida in five years.

INJURED GATORS

Florida was missing two key defenders, both out with ankle injuries - end Jabari Zuniga and linebacker Jonathan Greenard. Greenard entered the game leading the Gators with four sacks. Zuniga has three. Gators coach Dan Mullen was optimistic the two would be able to practice entering the Georgia game in two weeks.

ANGRY MUSCHAMP

South Carolina's Will Muschamp had grown so frustrated with officiating, he drew an unsportsmanlike conduct penalty. He was angrier still the flag was thrown far from where he stood, saying it was a ''gutless'' move.

''The guy ran 40 yards away and dropped a flag. I have no idea. I'd rather him drop it on my feet,'' the coach said.

UP NEXT

Florida is off next week before facing No. 10 Georgia in its annual rivalry game in Jacksonville, Florida, on Nov. 2.

South Carolina heads to Tennessee on Saturday.

---

More AP college football: http://apnews.com/tag/Collegefootball and http://www.twitter.com/AP-Top25

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