The 29-year-old, who played his last test against Australia in late 2023, missed out on a century when he was dismissed two balls from tea but was top scorer on a good day for the home side at the Gaddafi Stadium.
Captain Shan Masood contributed 76, and Mohammad Rizwan was 62 not out at stumps, along with Salman Ali Agha on 52 as Pakistan imposed themselves with the bat.
They won the toss and elected to bat on a pitch expected to become decidedly more difficult as the test progresses, but lost their first wicket after three balls when Kagiso Rabada had Abdullah Shafique trapped leg before wicket.
The dismissal was only confirmed after a South African review showed the ball swinging in to beat the inside edge.
Pakistan shrugged off the setback to keep up a steady scoring rate and were 92-1 at lunch with Imam reaching his half-century.
Even when Masood was lbw to Prenelan Subrayen for 76, ending a 161-run partnership, Pakistan still looked in control before losing two wickets in the last over before tea.
Imam was in a hurry to reach his ton and, attacking the bowling, got an inside edge to Senuran Muthusamy's left-arm spin and was snagged at short leg by Tony de Zorzi's sharp catch.
Saud Shakeel went next ball, the last before tea, as he leaned into his shot and hit it straight back to the bowler, who had to stretch to make the catch.
Pakistan were 199-5 at the end of the second session and then lost another wicket straight after as Simon Harmer had the dangerous Babar Azam leg before for 23.
But Rizwan and Salman added an unbeaten 114 runs for the sixth wicket to take Pakistan past the 300-run mark before the close.
The test is the first of the new World Test Championship cycle for both teams. South Africa won the last WTC in June when they beat Australia at Lord's.