The blast struck around midday as troops were leaving the base in Taji, 20 kilometers (12 miles), north of the capital, police said. Nineteen soldiers were among the dead, and several vehicles were damaged, they said.
The casualty toll was high because the attacker blew up the car while large numbers of soldiers were walking to and from a parking area for waiting minibuses that take them to and from work, officials said.
Insurgents frequently target members of the country's security forces in an effort to undermine confidence in the Shiite-led government. Although violence has ebbed in Iraq since the height of the insurgency, attacks still occur frequently.
Officials said many of the wounded were soldiers. They warned the death toll could rise further because several of the injuries were serious.
Hospital officials confirmed the casualties. All officials spoke on condition of anonymity because they were not authorized to talk to the media.
The attack was the deadliest in Iraq in more than a week. On Oct. 27, insurgents unleashed a string of bombings and other attacks around the country that left at least 40 people dead.
It was the second bombing in Taji in less than 24 hours. On Monday, police said a car bomb struck an army patrol not far from the site of Tuesday's blast, wounding eight people. Another bombing Monday near an outdoor market in a Shiite neighborhood on Baghdad's outskirts killed four.
In Iraq's north, the president of the country's self-rule Kurdish region urged Kurds in neighboring Syria to stay united and not let political differences devolve into violence.
The comments by Massoud Barzani, posted Monday evening on the regional government's website, point to growing concern in Iraq that infighting among Syrian Kurds could complicate that country's civil war and risk destabilizing Iraq's Kurdish region. Syria's Kurds have been solidifying control over territory where they live amid the tumult of the conflict.
Barzani over the summer brokered an agreement between rival Kurdish Democratic Union Party and the Kurdish National Council, the main Kurdish umbrella group, in Syria to jointly control Kurd-populated areas together.
Associated Press writers Bushra Juhi and Sinan Salaheddin in Baghdad contributed to this report.