COLUMBIA, S.C. – Florida coach Billy Napier found quarterback Graham Mertz and receiver Ricky Pearsall, both transfers, after the game and hugged them hard.

“This,” Napier said, “is why you come to Florida.”

Mertz threw for a career-best 423 yards and three touchdowns, the last a 21-yard strike to Pearsall with 47 seconds left, as the Gators rallied from 10 points down in the fourth quarter to beat South Carolina 41-39 on Saturday.

Pearsall had 10 catches for 166 yards, including the game-winner.

The joy and the determination were evident after Florida fell behind 37-27 when Spencer Rattler threw his fourth TD pass, a 33-yard scoring toss to tight end Joshua Simon with 9:11 to play.

Mertz cut into the lead with his 4-yard touchdown pass to tight end Arlis Boardingham with 4:40 to play. Then the Gators D forced a punt after the Gamecocks advanced to midfield.

Mertz, who entered second nationally in completion percentage (80%), threw three incompletes and faced fourth-and-10. That’s when he found Pearsall for a 26-yard gain.

The drive stayed alive when a ball off Pearsall’s hands was caught in stride by teammate Eugene Wilson III who took it to the Gamecock 16. Two plays later, Mertz faked with his shoulder and Pearsall was wide open just past the goal line.

“We came here today to prove something,” Napier said. “What a way to win a ballgame.”

Safety Miguel Mitchell picked off Rattler on South Carolina’s final possession. The Gators took a safety with 4 seconds left for their second straight SEC win.

The comeback ruined a brilliant performance by South Carolina’s Rattler, who passed for 313 yards and four touchdowns.

The Gamecocks (2-4, 1-3) have lost two straight and three of their last four.

“Disappointed that we got a 10-point lead in the fourth quarter and couldn’t finish it,” Rattler said. “That’s not like us.”

The Gamecocks trailed 27-24 on the last of four Trey Smack field goals midway through the third quarter. Two series later, Rattler led the go-ahead drive that included his 27-yard run into Florida territory and a 20-yard scoring toss to Trey Knox for a 31-27 lead.

Rattler was at it again the next time he got the ball, finishing a 70-yard drive with a 33-yard scoring toss to tight end Joshua Simon.

The first half was a classic shootout with the teams trading long drives and big plays. The teams combined for 521 yards and 26 first downs in a half where neither defense could make a stop.

Florida scored on four of its five first-half possessions and Smack’s fourth field goal, from 28 yards, sent the team into halftime ahead 24-21.

Rattler connected with four receivers on his touchdowns, including a 20-yard toss to tailback Mario Anderson where the Division II transfer leaped over safety Miguel Mitchell to reach the end zone.