The ongoing assault in Mazar-i-Sharif city comes just before the start of the Taliban's traditional spring offensive, set to be the first fighting season when Afghan security forces battle insurgents without full NATO support.
The assailants threw grenades and exchanged gunfire with Afghan security forces, setting ablaze one of the buildings in the compound, according to an AFP reporter at the scene.
"Our initial information shows that armed men entered the provincial Appeals Court in Mazar-i-Sharif today," Abdul Raziq Qaderi, acting police chief of Balkh province, told AFP.
There were no immediate reports of fatalities but at least 20 wounded people, including women and children, were brought to the provincial public hospital.
More From This Section
"Police, prosecutors and court staff were among those wounded," Noor Mohammad Faiz, a senior doctor at the hospital, told AFP.
The attack comes a day after an American soldier was killed by an Afghan counterpart in eastern Afghanistan, the first insider attack since Washington announced a delay in troop withdrawals from the country.
There was no immediate claim of responsibility for today's assault, which underscores Afghanistan's precarious security situation as US-led foreign troops pull back from the frontlines after a 13-year war against the Taliban.
President Barack Obama last month reversed plans to shrink the US force in Afghanistan this year by nearly half, an overture to the country's new reform-minded leader, President Ashraf Ghani.
Hosting Ghani at the White House for their first presidential head-to-head, Obama agreed to keep the current level of 9,800 US troops until the end of 2015.
The Taliban, who have waged a deadly insurgency since they were ousted from power in late 2001, warned that the announcement would damage any prospects of peace talks as they vowed to continue fighting.
The up-tick in attacks has taken a heavy toll on ordinary Afghans.
The number of civilians killed and wounded in Afghanistan jumped 22 per cent in 2014, a recent UN report said, as NATO troops withdrew from combat.