New Zealand were 427 for seven at tea on Friday, with the New Zealand captain on 207 not out.
Fleming and fellow left-hander James Franklin (46 not out) put on a record unbeaten 148 for the eighth wicket to take the advantage away from South Africa.
Both benefitted from dropped catches. Fleming gave a straightforward chance to first slip off Dale Steyn five balls after lunch when he was on 136, while Franklin was put down by Jacques Kallis, diving far to his left at second slip, off Makhaya Ntini when he 28.
Two runs later Franklin survived a concerted appeal for a catch behind off Ntini. In the next over he was struck on the helmet by a bouncer from Ntini and fell to the ground before resuming after treatment.
Apart from the dropped catch, it was a masterly performance by Fleming. He acknowledged after reaching his century on the first day that he did not have a good record of converting fifties into hundreds, but he has now turned three out of nine centuries into doubles.
Fleming went past the previous highest score by a New Zealander against South Africa, 170 by Scott Styris in Auckland in 2003/04, and went on to notch the highest score by a visiting player in 40 Tests at Newlands, beating the 189 by Jim Burke for Australia in 1957/58.
Fleming reached his double century off 331 balls with 28 fours, with his second hundred made off 141 deliveries.
Franklin, who has made a first-class double century, confirmed his reputation as a capable batsman as he and Fleming humbled the South African bowlers on an easy-paced pitch. It was the best eighth wicket stand in Tests between the two countries.
The only wicket to fall was that of Daniel Vettori, in the third over of the day and the first with the second new ball. Vettori pulled Ntini's first delivery for four but in trying to repeat the shot two balls later he spooned a catch to Andre Nel at mid-on.
Instead of whipping through the rest of the batting, South Africa's bowlers failed to find a consistent line and length and did not manage to bowl a maiden until Kallis sent down the 36th over of the day. By then New Zealand were in command.
The start of play was again affected by the vagaries of Cape Town's autumn weather. After a delay on the first day because of dew, a portable hovercraft was brought in to dry the outfield, but fog swept over the ground and play only started 55 minutes before lunch, with 83 overs scheduled for the day.
South Africa lead the three-match series 1-0.