Ganguly made 83 and fellow left-hander Pathan went on to score an unbeaten 111 as the Indians recovered from 69 for five to reach 316 for seven at the end of the first day of a four-day match on Thursday.
Ganguly, 34, who had not played for India since a series against Pakistan in February, came in at 37 for three while fast bowler Morne Morkel was causing havoc among the Indian batsmen.
Morkel, who finished the day with four for 74, took all his wickets before lunch after the Indians were sent in to bat by the Rest's captain, Jacques Rudolph.
India, battered by South Africa pace when they lost a one-day series 4-0, looked headed for humiliation in their only warm-up match ahead of the first Test starting in Johannesburg next Friday.
Openers Wasim Jaffer and Virender Sehwag were both out for ducks with the match only seven deliveries old. Jaffer was leg before to Mornantau Hayward in the first over and Morkel yorked Sehwag with his first ball of the match.
Morkel followed up with the key wicket of Sachin Tendulkar, who was caught at second slip, and Ganguly then watched from the other end while Morkel had VVS Laxman also caught at second slip and Mahendra Singh Dhoni caught behind. Laxman was captaining the side in place of the injured Rahul Dravid.
Ganguly had to survive some aggressive bowling. He was struck on the helmet by a bouncer from Hayward and gave a sharp chance to gully off Morkel soon after lunch as he and Pathan rebuilt the innings.
The two left-handers put on 139 for the sixth wicket as the pitch eased under a hot sun. Ganguly was eventually caught behind off Friedel de Wet, one of two late replacements in the Rest team. De Wet and Alfonso Thomas played in place of Vernon Philander and Garnett Kruger, who were injured.
Ganguly faced 141 balls and hit 13 fours in his innings.
Pathan and the hard-hitting Harbhajan Singh, who made 47 off 67 balls, added 79 for the seventh wicket to enable the tourists to finish the day in a reasonably strong position.
Pathan, who reached his century off 161 balls, had faced 176 deliveries by the close. He hit 15 fours and a six.
Morkel, 22, has been tipped by legendary South African fast bowler Allan Donald as a Test prospect and he underlined his potential during his opening spell.
Hayward also bowled with pace and aggression but unorthodox left-arm spinner Paul Adams, named in South Africa's squad for the first Test, conceded 54 runs off nine overs.
India 316 for 7 (Irfan Pathan 111 n o, Sourav Ganguly 83, Harbhajan Singh 47, Laxman 23; M Morkel 4 for 74, Thomas 1 for 39, Hayward 1 for 59) Vs Rest of South Africa