Shaw was 15-of-23 for 279 yards for the Gamecocks (8-2, 6-2 Southeastern Conference), who finished with six league wins for only the second time in 20 years of SEC play.
Arkansas (4-6, 2-4) will now have to beat both Mississippi State and LSU to make a bowl game after starting the season No. 10 in the country.
It was only the second win over the Razorbacks in the last seven games for the Gamecocks and it broke a three-game losing streak during which the Hogs embarrassed South Carolina by double-digits.
The Gamecocks scored on their first possession on a 29-yard touchdown throw to freshman tight end Jerell Adams. Arkansas' defense, ranked 12th in the SEC, forced South Carolina to punt on the next two possessions. They wouldn't stop the Gamecocks again until Tevin Mitchell intercepted Shaw in the end zone early in the fourth quarter.
A 10-yard Shaw run put South Carolina up 14-7, then Gamecocks coach Steve Spurrier went for it on fourth down from the Razorbacks 42 with 1:30 left in the first half. Arkansas blitzed, leaving Bruce Ellington wide open for a touchdown pass that gave South Carolina a 21-10 lead at half.
The Razorbacks held South Carolina to a field goal and appeared to be driving for a touchdown to stay in the game, aided by two straight personal fouls by the Gamecocks. But D.J. Swearinger ran an interception back 69 yards for a TD that essentially put the game away with South Carolina up 31-10. Swearinger, who had a shot to the head the play before that might be reviewed by the SEC office, threw the ball in the stands, drawing South Carolina's third straight personal foul.
The Razorbacks had their own problems. Tyler Wilson threw two interceptions for Arkansas and Dennis Johnson fumbled the ball trying to stretch for a first down at the South Carolina 5 early in the second quarter.
South Carolina's defense only allowed the Razorbacks two touchdowns in five trips inside the 20, with one of the scores coming with just 39 seconds left in the game.
Bruce Ellington had five catches for 104 yards, while Kenny Miles ran 14 times for 37 yards and caught three passes for 44 yards. The senior was again called on to be the main running back after Marcus Lattimore was injured.
South Carolina was playing its first game this season without its star junior, who suffered a horrific knee injury against Tennessee that might keep him out until 2014. The team honored Lattimore by putting up a banner marking his career touchdown record and the junior thanked fans with a recorded message played on the video board, promising to work hard to get back on the field. The South Carolina band also honored Lattimore by spelling out "We (heart) 21" at halftime.
Cobi Hamilton caught four passes for 72 yards, giving him Arkansas' season receiving yards record a 1,149 yards. Wilson was 26-of-41 for 277 yards, while Jonathan Williams ran seven times for 61 yards.