The blast occurred about 12:45 p.m. local time after the vehicle passed through a first security checkpoint, according to Interior Ministry spokesman Nasrat Rahimi.
Police identified the attacker at the second checkpoint but were unable to stop him before he detonated the explosives near the old Ministry of the Interior building, he said.
The injured have been taken to hospitals across the Afghan capital, said spokesman Wahid Majrooh of the Ministry of Public Health, who confirmed the casualties.
Taliban spokesman Zabiullah Mojahid claimed responsibility for the attack.
Of those killed, 14 were foreign nationals and eight were Afghans, according to the Ministry of Interior. Six gunmen were killed by Afghan security forces. The Taliban claimed responsibility for the assault.