A young man accused of stabbing a celebrated secular writer at a seminar targeted him because he was an 'enemy of Islam', Bangladesh investigators have said.

Zafar Iqbal was attacked yesterday in the northern city of Sylhet as the latest in a series of stabbings of secular or atheist authors and bloggers in Muslim-majority Bangladesh.

Prime Minister Sheikh Hasina, whose government has waged a fierce crackdown on homegrown extremism in recent years, blamed 'religious fanatics' for the assault.

Iqbal, a longstanding champion of free speech and secularism, remains in a stable condition after being flown to a military hospital in Dhaka with stab wounds to his head.

Police detained 21-year-old Faizul Hasan, a former Islamic seminary student, and were investigating any ties to the radical groups.

Colonel Ali Haider Azad Ahmed from the elite Rapid Action Battalion unit said Hasan told investigators it was 'his duty as a Muslim to resist those who work against Islam'.

Zafar Iqbal (pictured on a stretcher after the attack) was stabbed yesterday in the northern city of Sylhet in Bangladesh

'He has said Dr Zafar Iqbal was an enemy of Islam,' Ahmed told AFP.

Police said Hasan, whose father was a teacher at an Islamic seminary, may have had links to extremists blamed for attacks on secular and atheist writers in the last four years.

Suspected Islamist radicals have killed around a dozen such writers and bloggers, including an American atheist blogger of Bangladeshi origin.

Police have blamed homegrown Islamist extremist group Ansarullah Bangla Team - also known as Ansar-al Islam and linked to Al-Qaeda in the Indian Subcontinent - for most of the attacks.

Bangladesh's government has provided security for top secular writers and activists since Islamist extremists named them in several lists of targets.

Iqbal, 64, is a bestselling author and celebrity speaker who regularly appears at campuses nationwide. The US-trained professor teaches at a state university in Sylhet

Iqbal, 64, is a bestselling author and celebrity speaker who regularly appears at campuses nationwide. The US-trained professor teaches at a state university in Sylhet.

The attack was swiftly condemned by protesters in Dhaka and Sylhet, who staged torchlit marches and planned further rallies to demand justice later Sunday.

Hasina urged Bangladeshis to remain alert to the threat of extremism.

'Those responsible for these incidents have become religious fanatics,' she said Sunday.

'They think that they'll go to a heaven, but they will actually go to hell, because no one goes to heaven by killing a human being.'

In recent years Iqbal had supported the execution of top Islamist party leaders -- key opponents of Hasina -- for their part in war crimes in the early 1970s, despite allegations the prime minister was crushing dissent.

Bangladesh has been waging a war against extremists in the wake of numerous attacks by radical groups in recent years.

In July 2016, militants stormed a Dhaka cafe and massacred 22 hostages, including 18 foreigners, in an assault claimed by the Islamic State group.