Government sources said the attackers might have been trying to free their colleagues imprisoned on the premises of the compound, said information minister for Khyber Pakhtunkhwa province Mian Iftikkar Hussain.
Security forces engaged in a gun-battle with the militants and Hussain initially said that the attackers might have also taken some people as hostage. He later said that the situation was under control.
Among the injured was a female judge, a local police officer said. The area had been cordoned off and elite commandos were sent to deal with the attackers. The injured were helped by others to escape. They were taken to the hospital in stretchers.
Peshawar is located on the border of the country's semi-autonomous tribal region, the main sbase of the Taliban militants.
No group has yet claimed responsibility for Monday's attack.