Chuck Hayes added 15 points and 10 rebounds for Kentucky (10-1, 1-0 Southeastern Conference), which won its league opener for the 17th time in 18 years. The only loss during that stretch came in 2002 to Mississippi State.
Kentucky will play its final nonconference game of the regular season Sunday, when the Wildcats host No. 2 Kansas.
South Carolina (8-4, 0-1) has lost three games to ranked teams this season, having also dropped four-point road decisions at Kansas and No. 16 Pittsburgh. The Gamecocks' four losses have been by a combined 13 points.
Kentucky used a 7-0 run midway through the second half to turn a two-point lead into a nine-point advantage, the largest enjoyed by either team, with 8:55 left.
South Carolina cut that lead to five four times, but came no closer until a meaningless basket in the final seconds.
Kentucky's Ravi Moss and Patrick Sparks combined to make 4-of-8 free-throw attempts in the final 1:09, and Moss, a walk-on, also blocked a 3-point attempt by Josh Gonner with 23 seconds left that would've cut the Wildcats' lead to three.
South Carolina shot 53.6 percent from the field, snapping Kentucky's 42-game streak of holding opponents under 50 percent shooting. Tre Kelley led the Gamecocks with 19 points.
Kentucky made its first seven shots and jumped out to a seven-point lead, but South Carolina took control by shooting 58.6 percent from the field in the half. The Gamecocks made six 3-pointers in the first half, including one at the buzzer by Carlos Powell that gave them a 41-35 lead.
Powell had 13 of his 15 points in the first half.
After its initial run, Kentucky made only eight of its next 27 shots.
Kentucky scored the first seven points of the second half to regain the lead, starting a stretch during which the teams traded the lead on five straight possessions.
South Carolina went 2-of-10 from 3-point range in the second half. Gonner added 13 points for the Gamecocks.
Kentucky had five players score in double figures for the first time this season. Rajon Rondo had 11 points, while Sparks and Randolph Morris scored 10 each. The Wildcats committed only nine turnovers.
Kentucky repeatedly went inside and shot 20 more free throws than the Gamecocks. The Wildcats went 17-of-29 from the line, while South Carolina was 7-of-9.
South Carolina is 1-18 against Kentucky in Lexington, winning only in 1997. But four of the last five games between the teams at Rupp Arena have been decided by seven points or less.