Nahed Hattar's relative
A relative of the Jordanian writer Nahed Hattar holds his picture Reuters/Muhammad Hamed

A Jordanian writer was shot three times in the head as he made his way to a hearing over charges of contempt of religion.

Nahed Hattar, a self-described "non-believer", had shared a cartoon on Facebook showing a bearded man in heaven smoking, lying in a bed with women and calling on God to bring him wine and cashews.

He removed the cartoon shortly after posting it, saying "it mocks terrorists and their concept of God and heaven. It does not infringe God's divinity in any way".

He was arrested in August by Jordanian authorities, and charged with inciting sectarian strife and insulting Islam.

As he arrived at court on Sunday (25 September) he was shot. Witnesses said the gunman, bearded and in his 50s, was wearing a traditional Arab dishdasha.

According to the Jordanian state news agency, Petra, a man was arrested at the scene of the shooting in the Abdali district.

Hattar's family said they felt Jordan's prime minister, Hani al-Mulki, was to blame for the writer'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," the victim's cousin Saad Hattar said.

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

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

Sara Williams, a Jordan-based journalist, told Al-Jazeera that Hattar had been detained in the past over critical postings about Jordan's king.

"This was not his first brush with the law, but people I have spoken to are shocked about today's events," Williams said.

Hattar was an outspoken supporter of Syrian president Bashar al-Assad and had advocated removing legal and civil rights from Jordanians of Palestinian origin.