More than 50 people have likely died in a Taliban attack on a Afghan military base, US officials have said.

The attack targeted a mosque and dining facility on the base in Mazar-i-Sharif, Balkh province, according to the US military.

Six attackers in two military vehicles told guards at the base gates that they were carrying wounded soldiers and urgently needed to get in, said army spokesman Nasratullah Jamshidi.

After killing at least eight soldiers and wounding 11 others with rocket-propelled grenades and guns, one attacker was killed and the other five arrested, he said.

But responding Afghan forces killed "several" Taliban fighters, the US said.

The Western-backed Afghan government is locked in a prolonged war with Taliban insurgents as well as other militant groups.

Taliban spokesman Zabihullah Mujahid said the fighters set off an explosion, allowing suicide bombers armed with small arms to breach the base. “Our fighters have inflicted heavy casualties on the Afghan army stationed there,” he said.

The base is the headquarters for the Afghan National Army's 209th Corps, which covers most of northern Afghanistan, including Kunduz province where there has been heavy fighting.

A number of German and other foreign soldiers are based in Mazar-i-Sharif, including about 70 who advise the corps headquarters as part of a Nato-led multinational mission to advise and train the Afghan security forces.