Gayle (31) and Ganga (nine) had some anxious moments against Umar Gul and Shahid Nazir on a slow pitch with variable bounce after the home side, who resumed on 257 for seven, were bowled out.
Gayle, dropped on 12 at cover by Imran Farhat, stroked four boundaries through the off-side and Pakistan, encouraged by the dry pitch, introduced leg-spinner Danish Kaneria in the ninth over.
Seamers Daren Powell and Corey Collymore wrapped up the Pakistan innings, which was shored up by a gritty last-wicket stand of 32 from 46 balls between Umar Gul (26) and Kaneria (seven not out).
Gul struck five fours in his 44-ball knock after Pakistan lost overnight pair Nazir (nought) and Kamran Akmal (31) fairly quickly.
Nazir was bowled in the second over of the day by Powell and Collymore extracted Akmal's middle stump with the first delivery of the second new ball.
Akmal added 13 runs to his overnight score, hitting four boundaries.
Collymore finished with figures of three for 57.
Pakistan lead the series 1-0 after winning the first test in Lahore by nine wickets. The second in Multan ended in a high-scoring draw.
Pakistan (overnight 257/7) 304 all out (Mohd Yousuf 102, Imran Farhat 47, K Akmal 31, U Gull 26; Collymore 3 for 57, Bravo 2 for 33, Powell 2 for 83) vs West Indies 42 for 0 (Gayle 31 n o, Ganga 9 n o)