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
Updated Scout 300 Trend Meter For 2017The updated Scout 300 Trend Meter for the 2017 class takes a look at which schools are trending for each uncommitted member in the Scout 300.
SEC football grad rates, first to worstSee the newly released Graduation Success Rates for every SEC football program.
Week 12 CFB Rushing LeadersCheck out who put up big rushing numbers week 12 in college football.
Week 11 College Football PredictionsWeek 11 college football predictions for the 10 biggest games. The Pac-12 takes center stage for the first time all year, as red-hot USC travels to Seattle to take on unbeaten…
Chad Terrell Commits to South CarolinaThe No. 5 wide receiver in Georgia is going to take his game to the SEC. Chad Terrell has committed to South Carolina and he talks about that here...