A gunman has shot dead prominent Jordanian writer Nahed Hattar outside a court where he was facing charges for sharing a cartoon deemed offensive to Islam, state news agency Petra reported.

Hattar was struck by three bullets before the assailant was arrested on Sunday, said Petra. Witnesses said that a man had opened fire in front of the court in Amman's Abdali district.

The 56-year-old Christian was arrested on August 13 after posting a caricature on his Facebook account that depicted a bearded man in heaven smoking in bed with women, asking God to bring him wine and cashews.

Many Jordanians considered it offensive and against their religion. The authorities said Hatter, a prominent activist and a supporter of Syrian President Bashar al-Assad, violated the law by widely sharing the caricature.

He was charged with inciting sectarian strife and insulting Islam before being released on bail in early September.

Jordan is a leading member of the US-led coalition fighting the Islamic State of Iraq and the Levant (ISIL) group in neighbouring Iraq and Syria, and was the target of a June 21 suicide bombing that killed seven border guards.

The kingdom has carried out air strikes targeting ISIL, also known as ISIS fighters and hosts coalition troops on its territory.