A prominent Jordanian writer on Sunday was shot dead in front of the courthouse where he had been on trial for sharing a cartoon deemed offensive to Islam.



There were no immediate details on the identity or motive of the gunman. But a witness described the shooter, who was immediately arrested, as wearing a long grey robe and long beard characteristic of conservative Muslims. The shooting was the latest in a string of deadly security lapses in Jordan.



Police and relatives said Nahed Hattar was preparing to enter the courthouse for a hearing when the lone gunman shot him at close range.



"He was standing at a short distance of about one meter in front of Nahed on the stairs of the Supreme Court," the witness told The Associated Press on condition of anonymity, fearing repercussions.



The witness said seven shots were fired, and that Hattar was shot in the head. The official Petra News Agency said Hattar was shot three times.



Hattar, 56, was detained in August after sharing a cartoon on Facebook. The caricature depicted a bearded man in heaven, smoking and in bed with two women, asking God to bring him wine and cashews.



Relatives said the cartoon was meant to illustrate what Hattar, a secular Christian, viewed as the twisted religious views of Islamic State (ISIS) extremists. The post was quickly deleted after many angry responses.



Hattar was briefly detained for two weeks before he was released on bail.



Saad Hattar, a cousin, said relatives and friends of the writer apprehended the killer.



"Nahed was accompanied with two brothers and a friend when he was shot. The brothers and the friend chased the killer and caught him and handed him over to the police," he said.



He said the family held Jordan's prime minister, Hani al-Mulki, responsible for Nahed's death.



"The prime minister was the first one who incited against Nahed when he ordered his arrest and put him on trial for sharing the cartoon, and that ignited the public against him and led to his killing," Saad Hattar said.



In a statement, the family called on the government to hold accountable all those who had incited against Hattar.



"Many fanatics wrote on social media calling for his killing and lynching, and the government did nothing against them," they said.



Jordan is a close Western ally and has been largely spared from the violence engulfing neighboring Syria and Iraq. But a series of recent attacks has raised concern about security in the kingdom.



Late last year, a Jordanian police captain opened fire on instructors at an international police training center in Jordan's capital, killing at least five people, including two Americans, before being shot dead by security forces. In June, a suicide car bomb attack near the Syrian border killed seven Jordanian soldiers.



Hundreds of Jordanians have been sentenced to prison, are awaiting trial or are being held for questioning about links to ISIS. Under toughened anti-terror laws, even liking or sharing the group's propaganda on social media can land someone a prison sentence.