Nahed Hattar was struck by three bullets before the alleged assassin was arrested at the scene of the shooting in Amman's central Abdali district, said the official Petra news agency.
The assailant -- bearded and dressed in a grey dishdasha worn by conservative Muslim men -- shot Hattar, a 56-year-old Christian, as he made his way up the steps outside the court, a security source told AFP.
Hit in the head, he was pronounced dead on arriving at hospital, the source said.
The gunman, a 49-year-old resident of the capital, gave himself up to police at the court, the source added. Media reports said he was a former preacher in an Amman mosque.
An AFP journalist saw blood on the steps of the building where police had cordoned off the area of the shooting.
Mohammad al-Jaghbir, Hattar's friend, told AFP he had witnessed the killing.
"We were climbing the steps when a bearded man... got a pistol out of a bag he was carrying and fired at Nahed Hattar," he said.
Hattar's family said the writer had no protection despite having asked for it after receiving death threats on Facebook and by phone.
Hattar was a political commentator known for his antipathy towards Islamists including Jordan's Muslim Brotherhood and also his support for Syrian President Bashar al-Assad.
The cartoon Hattar posted on his Facebook page featured an illustration of God under the title "God of Daesh", using an Arabic acronym for the Islamic State group.
It depicts a bearded man in bed smoking with two women lying to either side, addressing God as a servant.
He asks for a glass of wine, cashew nuts and orders someone to clean the floor, before telling God to knock before entering next time.
Any depiction of God is prohibited in Islam.
Signup to our newsletter and follow us on Facebook and Twitter!
Hattar removed the cartoon after it triggered outrage on social media.
At the time, he explained on Facebook that the cartoon made fun of "terrorists and how they imagine God and heaven, and does not insult God in any way".
He was arrested on August 13 and charged with inciting sectarian strife and insulting Islam, before being released on bail in early September.
The attorney general had imposed a blackout on media coverage of the case against Hattar, who was also known as a leftist.
Prime Minister Hani al-Malki had ordered Interior Minister Salam Hammad to summon the writer and to initiate legal proceedings against him.
On Sunday Hattar's brother Majed, who accompanied him to his trial, blamed the government for his death.
"We hold the prime minister, the minister of the interior and the security services responsible for Nahed's killing," Majed said.
"Nahed Hattar was killed in cold blood in front of the highest institution of justice in Jordan."
The government denounced the killing as "heinous" and said the law would be "firmly applied to the person who committed the crime".
The opposition Muslim Brotherhood and Dar al-Iftaa, the highest religious authority, also condemned the attack.
Jordan is a leading member of the US-led coalition fighting IS in neighbouring Iraq and Syria, and was targeted in a June 21 suicide bombing that killed seven border guards.
The kingdom has carried out air strikes targeting IS jihadists and also hosts coalition troops on its territory.
In recent years, extremists have attacked other publications for publishing caricatures seen as insulting to Islam, including in Europe.
In January 2015, jihadists killed 12 people, including eight staff, in an attack on the Paris offices of satirical magazine Charlie Hebdo, which published drawings purporting to show the Prophet Mohammed in 2006.