Annan: A gunman has shot dead Jordanian writer Nahed Hattar outside the court where he was to stand trial on charges of contempt of religion after sharing on social media a caricature seen as insulting Islam, witnesses and state media said.

The gunman was arrested at the scene, state news agency Petra said. A security source said he was a 39-year-old Muslim preacher in a mosque in the capital.

An ambulance transports the body of Nahed Hattar to a medical facility after he was shot dead in front of a courthouse. Credit:AP

Hattar, a Christian and an anti-Islamist activist who was a supporter of Syrian President Bashar al-Assad, was arrested last month after he shared a caricature that depicted a bearded man in heaven smoking in bed with women and asking God to bring him wine and cashews.

In the cartoon, the man also asks God to clear his dishes and put a door on his tent and knock before entering.