A NATO spokesman said the explosion had caused "massive damage" to the building, where around 30 people normally worked.
Heavily armed attackers followed up the blast, battling with Afghan and German security forces late into the night.
"Germany, which heads the NATO-led Resolute Support mission in northern Afghanistan, has about 850 soldiers at a base on the outskirts of Mazar-i-Sharif, with another 1,000 troops coming from 20 partner countries."
"The suicide bomber was driving a truck full of explosives and hit the wall of the consulate office of our allied country Germany. As a result, there were some casualties near the building of the consulate but thank God all diplomat and members of the consulate are secured and safe. We reacted quickly with NATO Special Forces and entered inside the consulate. We have evacuated all diplomats to Marmal base," Abdul Razaq Qadiri, deputy police chief of Mazar Sharif, said.
The Taliban claimed responsibility for the attack, saying it was in retaliation for NATO air strikes against a village near the northern city of Kunduz last week in which more than 30 people were killed.
The heavily protected consulate is located in a large building close to the Blue Mosque in the centre of Mazar-i-Sharif, where the Indian consulate was also attacked by militant gunmen earlier this year.
12