The attackers were described as insurgents dressed as members of the Afghan National Army, CNN reported.
About three dozen of the dead were civilians and the rest were 10 Afghan security forces. Nine of the attackers died, said provincial Gov. Mohammad Akram Ekhpelwak.
Officials said a bomb-filled vehicle exploded outside the courthouse, part of a provisional government complex, while a trial of Taliban suspects was proceeding, the BBC reported.
Taliban insurgents claimed responsibility for the attack.
Farah Deputy Gov. Mohammad Yunus told a private Afghan television station militants detonated a "large explosive-laden vehicle" that damaged both government and non-government buildings.
After the initial assault, militants positioned themselves in several buildings, Yunus said.
An Afghan security source told the BBC, "First there was a suicide attack, later on a group of attackers started fighting."
Notable deaths of 2014 [PHOTOS]