Monir Ahmad Farhad, a provincial spokesman, said Friday four people were killed and more 100 people were injured when the attack happened at 10:45 p.m. in Mazar-e-Sharif, the provincial capital. No German diplomats were hurt.
Local police chief Abdul Razaq Qaderi described the explosion as "very powerful" and said three police officers were injured.
The Taliban claimed responsibility for the attack in an email to the media.
Taliban spokesman Zabiullah Mujahid said the target was the consulate and he referred to Germany as "the invader."
Mazar-e-Sharif is one of the most peaceful cities in Afghanistan. It is also one of northern Afghanistan's most populated and developed cities. While the Taliban are active around Mazar-e-Sharif, the city is not a Taliban stronghold.
The attack comes seven days after a a joint Afghan-US battle against the Taliban in the northern district of Kunduz that killed 30 civilians
as well as two US soldiers and 26 militants.
"I deeply regret the loss of innocent lives, regardless of the circumstances," Gen. John W. Nicholson, commander of US forces in Afghanistan, said in a statement Saturday.
The troops came under fire during what the US military said was a mission to train, advise and assist its Afghan partners in clearing a Taliban position and disrupting the organization's operations in Kunduz district.
Those deaths happened the same day Taliban mortars killed at least seven people at a wedding party in Faryab province in northern Afghanistan, police spokesman Kareem Youresh said. At least 13 people were wounded.
Kunduz has been the site of a number of anti-Taliban operations. In April, the Pentagon announced that 16 military personnel would be disciplined over a fatal US strike on a Kunduz hospital in October 2015. But the military said the strike was not a war crime because it resulted from unintentional human error and equipment failure.