GAINESVILLE, Fla. (AP) — Feleipe Franks silenced the home crowd twice after touchdown runs, seemingly sending a message after getting benched last week and booed earlier in the game, and No. 19 Florida rallied to beat South Carolina 35-31 Saturday and end a two-game losing streak.

Franks dived across the goal line on a fourth-down play from inside the 1-yard line with 4:09 to play, putting the Gators (7-3, 5-3 Southeastern Conference, No. 15 CFP) ahead for the first time and for good. Florida overcame a 17-point deficit in the second half.

C.J. Henderson ended the Gamecocks’ comeback attempt by picking off Jake Bentley.

But Franks was the player of the game, even if he thrived in a villain role. The sophomore put his fingers to his lips while celebrating with teammates, the kind of gesture usually seen from visitors.

Franks completed 15 of 21 passes for 161 yards and a touchdown. He also ran for two scores a week after getting pulled for the third time in two seasons.

Coach Dan Mullen opened up the quarterback competition, but backup Kyle Trask broke a foot in practice Wednesday and is out for the season. That left Franks as Mullen’s only viable option.

Fans expressed their displeasure after consecutive plays on the first series in which Franks fumbled and badly overthrew a receiver.

South Carolina (5-4, 4-4) scored touchdowns on its first two possessions and looked like it would roll in the Swamp.

But Franks and the Gators woke up and rallied, preventing former coach Will Muschamp from getting a victory in his second trip back to Florida Field since getting fired.

Jordan Scarlett ran for 159 yards. Lamical Perine added 107 yards and two scores on the ground.