South Africa were 70 for three in their second innings at the close of play, still 33 behind Australia's first innings total of 308.
Fast bowler Lee struck twice within three balls in his third over as South Africa set out to erase a 103-run first innings deficit.
Then leg-spinner Warne had South African captain Graeme Smith leg before wicket with his third delivery.
South Africa's collapse came at the end of a day when their bowlers staged a fightback after it had seemed Australia would take a big lead.
Matthew Hayden (94) and captain Ricky Ponting (74) put Australia in command with a second wicket stand of 154 but Ponting's dismissal just before lunch started a slide in which they lost nine wickets for 133 runs.
"We would like to have had some more runs," said Hayden, "but it's going to be a really hard wicket for batsmen to start on.
"We've seen a lot of wickets falling, which is pretty indicative of the conditions. We got a 100-run lead and they're three wickets down, so we're looking in a pretty solid position."
Ponting fell when he drove Jacques Kallis to Andrew Hall at short cover after facing 112 balls and hitting eight fours and a six.
Hayden, having survived some anxious moments with three edged strokes which took him from 28 to 37, was on course for his 26th Test century until he top-edged a pull against Makhaya Ntini and was caught by Jacques Rudolph, running in from deep midwicket. He had faced 173 balls and hit 14 fours and a six.
He said he was frustrated to have got out within sight of a century for a second successive time in a Test at Newlands, after making 96 four years ago, although he admitted having ridden his luck in this innings.
Hayden said: "It's a really difficult wicket, with a lot of sideways movement. We wouldn't want to be chasing 300 here."
The innings lost momentum as Michael Hussey and Damien Martyn were caught behind off Hall and Kallis respectively, bringing the hard-hitting Andrew Symonds and Adam Gilchrist together. They added 36 in just 4.4 overs before Gilchrist slashed at Kallis and was caught by South African captain Graeme Smith at first slip.
All-rounder Jacques Kallis, who did not bowl until the 41st over, took three for 51, while Ntini, Andre Nel and Boje took two wickets each.
Nel said: "It was frustrating not to get wickets in the morning but we fought back well. If we can get a lead of 200 and then bowl well we have got a chance."
Smith batted aggressively at the start of the South African second innings but the tempo changed when AB de Villiers was caught behind off an inside edge when he attempted to drive Lee.
Two balls later Lee bowled a fast delivery which cut back sharply to bowl Herschelle Gibbs off an inside edge.
Smith went to Warne's third delivery and the ball spun sharply to hit him on the back pad, winning the verdict from umpire Billy Doctrove, although Smith appeared to have been hit outside the line of his off stump.
Kallis and Ashwell Prince batted through to the close, with Kallis looking in good form as he reached 31 not out. Prince was unbeaten on 14.
South Africa, first innings
Falls: 1-24, 2-42, 3-48, 4-61, 5-76, 6-104, 7-124
Australia, first innings
Fall: 1-21, 2-175, 3-192, 4-214, 5-236, 6-272
7-294, 8-294, 9-296
Umpires: Aleem Dar (PAK), B Doctrove (WIS)
TV umpire: K Hurter (RSA). Match referee: C Broad (ENG)