Virginia couldn't recover from the struggles of its first-inning defense.
The first of third baseman Steven Proscia's two errors, on what should have been an inning-ending groundout, opened the door for three unearned runs.
"Any time you make errors, it's frustrating, especially when you have a guy on the hill giving it all he's got," Proscia said. "I make that play in the first inning, that could change the total complexion of the game. Our defense has been there all year, and we just didn't have it tonight."
No. 1 seed Virginia (55-11) must beat California on Thursday to keep playing in Omaha.
Virginia finished with three errors, Will Roberts' 3 1-3 innings represented his shortest start of the year and the Cavaliers managed only five hits against three South Carolina pitchers.
"We're obviously disappointed in our play this evening," coach Brian O'Connor said. "South Carolina, really, quite frankly beat us in every phase of the game. Overall, we just didn't do the fundamental things that it takes to win a college baseball game at this level."
For South Carolina (52-14), the win continued one of the greatest runs in NCAA tournament history and put the Gamecocks in the best possible position to return to the best-of-three finals next week.
They won their 13th straight national tournament game, matching the record held by Southern California (1972-74) and LSU (1997-98). They also recorded their fifth win over a No. 1-ranked team.
Don't mention that to Gamecocks coach Ray Tanner, though.
"I like my team, but I don't like that talk," Tanner said. "We line up and we have some good athletes, but there are teams that have better athletes and some better arms.
"Truth of the matter is we have to do things really well to win. We can't throw our gloves out. We have to pitch and play defense and get timely hitting."
Colby Holmes, John Taylor and Matt Price combined on the five-hitter. The Gamecocks turned two double plays and almost another when second baseman Scott Wingo made an amazing backhanded flip of the ball out of his glove to shortstop Peter Mooney, whose relay to first was just late.
Adrian Morales and Brady Thomas had three hits apiece, and five of the Gamecocks' 13 hits went for extra bases.
"We played probably one of our better games of the year tonight," Tanner said, "and we certainly needed it playing a team the quality of Virginia."
The Gamecocks are off until Friday and would have to be beaten twice by Virginia or California to not return to the finals.
"It puts you in a good spot," center fielder Jackie Bradley Jr. said. "But we know that we're a long way from where we need to be. It's still early. We're not taking anything for granted."
John Taylor (11-2) got the win with one-hit relief over a season-high 4 1-3 innings. Price came on to record the final out.
Holmes held the Cavaliers hitless into the fourth inning, when John Hicks crushed a 1-0 pitch into the left-center seats for his eighth homer of the year.
Holmes matched his career high with seven strikeouts, but left in the fifth after Virginia loaded the bases on a single, walk and a misplayed ball that dropped for a hit.
Taylor relieved and induced an inning-ending double play, and the Cavaliers didn't advance anyone past first base the rest of the game.
"That was a big spot," Proscia said. "Their pitcher made a good pitch and they got the double play that they needed. That's what they were doing all night to us, and that's why they won."