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
Elite 2020 WR visits SEC rivalsCHARLOTTE, N.C. -- Providence Day 2020 receiver Porter Rooks is one of the top rising sophomores in the country and his recruitment continues to gain momentum.
Scout Football11:51 AM
Mailbag: Wrap-Up of Week One of Texans OTAsAnswering readers questions on the first week of work at OTAs for the Houston Texans.
State of the Texans6:48 AM
Ohio's Peters describes interest in TennesseeXavier Peters went in-depth to describe his trip down from Ohio to Tennessee and provided IT with an update on his recruitment.
Inside TennesseeYesterday at 3:07 PM
Steere talks KU offerWesleyan Christian 4-star big man Ian Steere talks about his new offer from Kansas.
Phog.netYesterday at 10:24 AM