KABUL, Afghanistan – Suicide bombers disguised as Afghan soldiers stormed a courthouse Wednesday in a failed bid to free more than a dozen Taliban prisoners in western Afghanistan, officials said. At least 44 civilians and nine attackers were reported killed in the fighting.

The assault in Farah province was the latest example of the Taliban's ability to strike official institutions despite tight security measures. The persistent violence has undermined confidence in President Hamid Karzai's government as it tries to take over its own security ahead of the withdrawal of international combat forces by the end of 2014.

Nine men wearing suicide vests drove into the center of the provincial capital, which has the same name, in Afghan national army vehicles that allowed them to bypass checkpoints, provincial police chief Agha Noor Kemtoz said.

Two of the attackers blew themselves up inside one of the vehicles while the others jumped out of the second and ran toward the courthouse and prosecutor's office, he said. Guards opened fire, killing one of the attackers, while the others engaged in a fierce gunbattle that left civil servants and government officials holed up in their offices.

Kemtoz, who gave the death toll, said the attack aimed to free 15 Taliban prisoners who were being transferred to the courthouse for trial, which had not yet started.

"Definitely the plan was to free the prisoners with this attack, but thank God, they did not succeed," he said. "All the prisoners are accounted for."

Dr. Abdul Hakim Rasouli, chief of the Farah hospital, said 80 people also were wounded.

Deputy provincial governor Yonus Rasouli said the explosion damaged many government buildings in the area.

Taliban spokesman Qari Yousef Ahmadi claimed responsibility for the attack in a text message sent to reporters.

Farah province, which is bordered by Iran to the west and Afghanistan's volatile Helmand province to the east, has seen an uptick in attacks against the local government in recent months as militants seek to disrupt efforts to stabilize the area.

In Kabul, meanwhile, Afghanistan's intelligence chief Asadullah Khalid returned to Kabul nearly four months after he was seriously wounded by a Taliban suicide bomber posing as a messenger of peace.

Billboards in the capital welcomed home the director of the National Directorate of Security on Wednesday, saying he has fully recovered and "is ready to continue his duty to provide peace, security and prosperity to his homeland."

In other violence, Taliban gunmen attacked a local police patrol late Tuesday in southeastern Paktika province and six insurgents were killed in the fighting, according to a statement from the governor's office. A roadside bomb then struck a police vehicle as it was leaving the area, killing four patrollers, it said.

Four police officers also were killed and one wounded Tuesday when their vehicle hit a roadside bomb in northeastern Kunar province during an operation to clear the area of explosives, government spokesman Wasifullah Wasifi said.