The Tigers (4-1, 2-0 Southeastern Conference) had struggled to move the ball against South Carolina's defense. Trotter had thrown two interceptions and was sacked four times by the Gamecocks (4-1, 2-1). But down 13-9, Barrett led Auburn on a 12-play, 57-yard drive that ended with a pass to wide open Lutzenkirchen in front of the goal line.
The junior fumbled the ball into the end zone, then recovered it just before sliding out of bounds to put Auburn ahead.
South Carolina advanced to Auburn's 29 on its final possession before time expired, though Gamecocks coach Steve Spurrier argued that clock should have stopped with 1 second left after a completed pass for a first down.
Michael Dyer ran for 141 yards on a career-high 41 carries and had a 1-yard TD for Auburn, which has won its past 11 SEC games.
It looked like South Carolina's defense would be enough to bail it out of trouble as quarterback Stephen Garcia again had problems putting up points against an Auburn defense that was ranked dead last in the SEC.
Instead, the Tigers D rose and held the Gamecocks to 54 yards and one first down in the final period. And Trotter and the Tigers found their groove just in time. They converted four third downs in the go-ahead drive, including the touchdown to Lutzenkirchen.
Auburn also did a good job on Marcus Lattimore, who came in as the SEC's leading rusher. He finished with 69 yards on 17 carries. Still, when Lattimore broke through for a 15-yard TD run midway through the third quarter, it appeared it might hold up the way South Carolina's defense was playing.
Melvin Ingram had 3 1/2 sacks and one of four South Carolina interceptions.
Trotter was 12 of 23 for 112 yards with two interceptions.
This one looked like a contest of who'd crack first: Auburn's last-in-the-SEC defense or South Carolina's can't-move-the-ball-too-well offensive attack that has struggled to score the past two weeks.
In the first half, it was the Tigers' D that came up bigger than it had this season. They held Lattimore to 36 yards on nine carries and the Gamecocks managed only four first downs on nine first-half possessions.
Garcia, a lightning rod for Gamecock criticism for his inconsistency, was at it again early on. An interception by Demetruce McNeal - Garcia's eighth of the season - ended one promising drive. When Garcia was short on a sideline play to Nick Jones, Spurrier stomped around in frustration.
Usually, it's Lattimore who bails the Gamecocks out but even he didn't look like himself. He fumbled on one drive and could not fight his way through Auburn's charged up defense.
Not that the Tigers had much success with South Carolina's defense, led by Ingram and safety Antonio Allen. Ingram had two of the Gamecocks three first-half sacks and picked off Auburn's chance to extend a 9-6 lead right before halftime.
The Tigers' reliable kicker Cody Parkey was lined up for a 32-yard field goal try with 1:06 left when holder Ryan White took the snap, rolled right and threw toward Lutzenkirchen near the goal line. But defensive end Ingram had dropped back in coverage to end the threat.
Alshon Jeffery, South Carolina's all-SEC receiver, had the one offensive bright spot the first 30 minutes with a 50-yard touchdown catch as he outmuscled defender T'Sharvan Bell for the ball. But that was just Jeffery's second TD grab of the year.
Dyer answered with his touchdown run to put Auburn up 9-6.
Late TD gives Auburn upset win
Gamecock Anthem Top Stories
Huffman's Stars of the Offseason- Part OneScout's National Director of Recruiting Brandon Huffman looks at the top players he saw at each position during the spring and summer camp and 7v7 circuit from the West region...
Scout Football1:00 PM
Marshall makes the call for IndianaGeorgia wideout Miles Marshall has committed to the Indiana football program.
2019 4-star OLB's recruitment surgingElizabeth City (N.C.) Northeastern junior outside linebacker Traveon Freshwater's stock continues to rise and he spoke with Scout about the latest developments in his recruitment.
Scout Football11:48 AM
Immanuel Bates has 3 he wants to visitPHILADELPHIA -- Which schools is four-star recruit Immanuel Bates planning to visit? Who are his most recent offers? Bates weighs in at the Under Armour All-American Camp.
Scout Hoops11:25 AM
UCLA 2018 Hoops RecruitingJuly 20 -- The second July evaluation period started Wednesday night, so here's an update on UCLA's targets for 2018...
Bruin Report Online10:40 AM