Smith, returning from a hand injury, scored 92 including a 94-run partnership with de Villiers. Batsman de Villiers finished just shy of a half-century with 49 runs.
Pakistan's bowlers struggled for much of the session, with the exception of Shoaib Akhatar, Mohammad Hafeez and Wahab Riaz who all took two wickets.
Abdur Rehman, replacing out-of-form Saeed Ajmal, bowled well though he took no wickets.
South Africa's performances put the team in a strong position to win the best-of-five series which it leads 2-1.