The Britain-based Syrian Observatory for Human Rights said the explosion on Sunday night took place in the suburb of Harasta, northeast of the capital.
"Three generals and a brigadier-general were among 31 troops killed in a bomb attack that caused a building in the army transport base in Harasta to collapse," said Rami Abdel Rahman, director of the watchdog group.
The timing of the attack is significant as it comes amid a major regime offensive on rebel positions all around Damascus, said Rahman.
"Only the night staff were on duty when the explosion occurred. If the bomb had gone off an hour before, there could have been up to 200 dead," he said by the telephone. He said others were wounded but the death toll was unlikely to rise.
The bomb appeared to have been placed "either inside or beneath the building in a tunnel", he added, suggesting there was a possibility rebels had infiltrated the base.
A rebel group, the Direh al-Aasmeh (Shield of Damascus) brigade, claimed responsibility for the attack.
The Observatory said it is not clear what type of bomb was used, but that the force of the blast leveled the building. A video distributed by the group, which is part of the Free Syrian Army, showed the building collapse completely.
There was no immediate confirmation from state media or Syrian officials.
In recent weeks, the army and pro-Assad gunmen have taken ground in the north while rebel fighters have resorted to bomb attacks and mortar strikes into government-held territory, including the capital.
Harasta is mostly in government hands but rebels have been trying since summer 2012 to advance into it.
More about: