Amman: A court in Jordan sentenced a 22-year-old man to death on Thursday for an attack on a security complex that killed five people in June, state news agency Petra said.

The state security court found Mohammad Masharfeh guilty of “committing terrorist acts that led to the death of human beings and committing terrorist acts using automatic weapons”.

Masharfeh pleaded not guilty to the charges at the start of the military-dominated court trial last month. An accomplice who was charged with “selling weapons for illegal use” was sentenced to a year in prison, the agency said.

The court heard Masharfeh entered the compound and opened fire on security personnel of the General Intelligence Department. He was arrested close to the scene. The compound is next to a large Palestinian refugee camp.

The rare attack on a security branch of the powerful intelligence apparatus jolted the US-backed Arab kingdom, whose relative stability has distinguished it from neighbours Syria to the north and Iraq to the east.

The government at first said the attack was linked to Islamist militants but later said the gunman was a resident of the refugee camp, which suffers a lack of economic opportunities, and had acted alone.

Family sources said the man was motivated by revenge after being mistreated by interrogators at the security facility when he was detained a week before the shooting.

International human rights activists say Jordan’s military courts lack proper legal safeguards and say there are growing cases of the mistreatment of detainees and of extracting confessions under duress. The government denies that it mistreats detainees.