COLUMBIA, Mo. (AP) -- Hobbled by a sprained left knee, Connor Shaw asked Steve Spurrier if he could play Saturday night at Missouri.
The South Carolina coach obliged, calling on Shaw in the third quarter down with the Gamecocks down 17 and starter Dylan Thompson struggling.
Shaw threw for 201 yards and three touchdowns in relief, engineering three fourth-quarter drives and helping the Gamecocks score on their final five possessions to stun No. 5 Missouri 27-24 in two overtimes.
''Dylan played awfully well most of the time he's played,'' Spurrier said. ''It was do or die. We had no chance in the division if we didn't win this one.''
Elliott Fry's 40-yard field goal proved to be the game-winner after Missouri's Andrew Baggett clanked a 24-yard attempt off the left goal post.
''He's a competitor,'' coach Gary Pinkel said of his kicker. ''You know, that's his job and it's his responsibility. Last week, he made five. . It's not one guy here. We all could have done something different to help win that football game.''
Shaw extended the game in the first overtime with a 15-yard touchdown pass on fourth down in the Gamecocks' first overtime to match the Tigers' Marcus Murphy's 1-yard scamper.
Missouri (7-1, 3-1) could have all but locked up the SEC East with a victory, instead South Carolina (6-2, 4-2) moves to within one game of the Tigers for the division lead, with home games against Mississippi State and Florida remaining.
Shaw engineered fourth-quarter scoring drives of 65, 69 and 63 yards, and the Gamecocks knotted the score at 17 on a two-yard reception by Nick Jones with 42 seconds remaining. Ellington scored his first touchdown on a 6-yard catch with 12:13 remaining, and Elliott Fry added a 20-yard field goal with 5:03 left.
Thompson started his third career game for the Gamecocks, throwing for 222 yards. The Gamecocks outgained Missouri 498-404, but couldn't convert until Shaw entered.
Mike Davis caught three screen passes on South Carolina's final scoring drive in regulation, partly making up for two fumbles in the first half. The Gamecocks turned the ball over three consecutive times in the second quarter, helping Missouri take a 14-0 halftime lead.
Davis, who led the conference with 125.6 rushing yards per game entering the night, committed his first miscue at the Missouri 29-yard line with 12:30 remaining in the half, and his second halted a 71-yard drive at the Tigers' 2-yard line with 5:46 left. He finished the night with 51 rushing yards and 99 receiving yards while backup Shon Carson added 27 on the ground and 14 through the air.
Spurrier noted that despite the fumbles, Davis' key role down the stretch helped the Gamecocks come back.
''I didn't lose hope at all,'' Davis said. ''Our guys, tonight we came together.''
Davis' second fumble set the stage for a 96-yard touchdown pass from Maty Mauk to L'Damian Washington for Missouri. Two yards deep in his own end zone, Mauk found Washington streaking toward the middle of the field for an easy first down, and then the receiver eluded two tackles at his 45-yard line before being untouched the rest of the way. The pass was Missouri's longest since a 98-yarder from Pete Woods to Joe Stewart at Nebraska in 1976.
Mauk struggled out of the gate, throwing a pass dropped by defender Sharrod Golightly and then an interception to Kaiwan Lewis, a far cry from the 41-yard pass and 20-yard touchdown toss he threw in his opening attempts last week in a 36-17 win against Florida. But Mauk then completed three of his next four to set up Missouri's first touchdown, an 11-yard scamper by Murphy with 1:23 left in the first quarter.
Mauk finished with 249 yards and a touchdown in his second career start, while Murphy totaled 53 yards on the ground.
The Tigers added a 27-yard field goal by Baggett with 6:46 left in the third quarter before he missed a 46-yarder in the fourth quarter wide left.
''I told our football team,'' Pinkel said. ''The loss will not define us. What will define this football team is how we deal with it. . It stings, you feel awful. You feel terrible, and that's OK. But we've got to get going. We have a real good football team.''
The Tigers still control the SEC East race, but should South Carolina win its final two conference games, they'll have to win their remaining four games starting next week at home against Tennessee to clinch a trip to Atlanta Dec. 7.