PESHAWAR, PAKISTAN — A gunman dressed as a lawyer shot and killed a prominent lawyer inside a courtroom in northwest Pakistan on Monday, police said.

The attacker, who was detained at the scene, opened fire on Abdul Latif Afridi, former president of the Pakistan Lawyers Union and a leading figure in the community, fatally wounding him. The attack took place at the Peshawar High Court.

The attacker, Adnan Khan, had previously accused Afridi of orchestrating the 2015 murder of his father, Samiullah Khan, who was also a lawyer, said Naeem Khan, a police officer.

It was not clear how the attacker managed to sneak into the court building with a gun. The assassination was condemned by Prime Minister Shahbaz Sharif, government officials, politicians and lawyers.

In a statement, Sharif expressed concern about the deteriorating security situation in the northwestern province of Khyber Pakhtunkhwa, where Peshawar is the capital. His main rival, the party of opposition leader and former Prime Minister Imran Khan, is in power in the provincial assembly.

Before his assassination, Samiullah Khan, the father of the attacker, had represented Shakil Afridi, the Pakistani doctor who helped the CIA find al Qaeda mastermind Osama bin Laden. Bin Laden was killed in 2011 by Navy SEALs in a raid on his hideout in Abbottabad, Pakistan.

The doctor conducted a fake vaccination campaign that helped locate and identify bin Laden. The doctor and lawyer killed on Monday are not related.

In 2012, Pakistan sentenced Shakil Afridi to 33 years in prison for allegedly providing money and medical treatment to Islamic militants in a former tribal region. Afridi and his family have denied those charges.

Pakistan was outraged that it had been kept in the dark before the SEAL operation. Washington demanded Afridi’s release, but Islamabad resisted the demand, saying he violated Pakistani law. The doctor was never formally charged in the bin Laden case.