An Islamic extremist has been arrested after an American blogger was hacked to death with a machete in the middle of the street.

Avijit Roy was on his way back from a university book fair in Bangladesh when he was targeted on Thursday by at least two men over his opposition to religious extremism.

They sliced his head with the long blades before turning on his wife, Rafida Ahmed, and cutting her finger off when she tried to save him.

Police in the country's capital Dhaka paraded their suspect, fundamentalist blogger Farabi Shafiur Rahman, before the media after arresting him earlier today.

Scroll down for video

Islamic extremist Farabi Shafiur Rahman (centre) has been arrested and paraded before the media after last week's murder of American blogger Avijit Roy. Mr Roy was hacked to death with a machete in the middle of the street on Thursday

Mr Roy with his wife Rafida Ahmed on holiday together at the Grand Canyon. She remains in hospital in a serious condition after she suffered head injuries and lost a finger in the attack

A source in the Rapid Action Battalion (RAB) said that an elite force had seen correspondence between former physics student Farabi and another person about killing Mr Roy.

Mufti Mahmud, a spokesman for the RAB, said: 'On different occasions, he exchanged [Roy’s] location, his identity and his family’s photographs with various people.

'He wrote: "Avijit Roy lives in America. So it’s not possible to kill him at this moment. But when he’ll return to the country, he’ll be murdered."'

Police added that Mr Roy's family had been threatened by the extremist, who is known for his Facebook postings against atheist writers, on several occasions on Facebook and Twitter.

Farabi posted on Facebook last year: 'It's a holy duty of Bangalee Muslims to kill Avijit.'

Major Maksudul Alam, another spokesman, said: 'He is the main suspect. [Roy’s] family told us that he got threats from Farabi several times.

Commander Mufti Mahmud Khan added: 'Farabi has admitted that he threatened Avijit but we are not sharing more information with you for the sake of the investigation. We need to ask him more.'

Farabi was previously arrested over the murder of another blogger, Ahmed Rajib Haide, in February 2013 but was released on bail.

The arrest comes a day after hundreds of mourners gathered around the blogger's coffin near Dhaka University to pay their respects. Ms Ahmed remains in hospital in a serious condition.

Shahriar Kabir, a writer, said at the memorial: 'Free thinking in Bangladesh is become a great danger, all the free thinkers are at great risk.

The scene immediately following the attack on the couple shows Ms Ahmed covered in blood. An obscure militant group, Ansar Bangla 7, claimed responsibility for the attack it said was in retaliation for his 'crime against Islam'

Ms Ahmed lying on a stretcher after the brutal attack. She is still recovering in hospital

A source in the Rapid Action Battalion (RAB) said the elite force had seen correspondence between Farabi (centre) and another person about killing Mr Roy

A RAB spokesman confirmed that Farabi (centre) is the main suspect and said that Mr Roy's family had been threatened by the extremist on several occasions

Mr Roy's family said Islamist radicals, like Farabi (centre), had threatened him over his blog, 'Mukto-mona,' or 'Freemind,' that highlighted humanist and rationalist ideas and condemned religious extremism

'We want to know why the government failed to ensure the safety of him, despite knowing that he had been facing threats from the Islamist radicals.'

As Mr Roy's father stood by, Kamal Hossain, the architect of Bangladesh's secular constitution, called the killing 'a heinous murder'.

'My question is, why did it take place?' said Mr Hossain. 'Avijit was killed because of his writing. By killing him, the killers have torn apart our constitution.'

People also held a demonstration at the spot where he was killed and chanted slogans demanding 'immediate arrest and quick trial of the perpetrator'.

The murder of Mr Roy, an atheist who advocated secularism in Bangladesh, came amid a crackdown on the country's Islamist groups after they increased their activities in recent years.

A resident of Atlanta, Georgia, Mr Roy came to visit Dhaka, the city of his birth, in the middle of last month and had been due to soon return home.

Friends and relatives of Mr Roy sob as mourners come to pay respects to the writer, whose murder came amid a crackdown on Bangladesh's resurgent Islamist groups

Mr Roy's father Ajoy Roy, seated right, is comforted by fellow mourners at his son's funeral earlier today. Hundreds came to see Mr Roy's coffin at Dhaka University and lay flowers before his burial

Mr Roy's family said Islamist radicals had threatened him over his blog, 'Mukto-mona,' or 'Freemind,' that highlighted humanist and rationalist ideas and condemned religious extremism.

The naturalised U.S. citizen, who was a bio-engineer as well as a blogger, had been receiving death threats online for years. Mr Roy and his wife have a daughter at university in the US.

Ajoy Roy stood alongside his son's coffin as mourners filed past.

He reiterated that Islamist militants were responsible for his son's death, but also blamed the government for failing to protect him despite repeated threats on his life.

'I am speechless at this moment of mourning. When the fundamentalists threatened, I informed the Inspector General of Police and Deputy Inspector General of Police,' he said.

'This murder has proved their utter failure.'

An obscure militant group, Ansar Bangla 7, claimed responsibility for the attack, which it said was in retaliation for his 'crime against Islam'.

The extremists also said he was singled out because he is a U.S. citizen - and characterized the vicious killing as 'revenge' for attacks on ISIS in Syria.

Orange and red flowers are laid on the coffin of Mr Roy as hundreds gather to pay their respects

Fellow mourners comfort Ajoy Roy as he looks down at his son's coffin at Dhaka University earlier today

A resident of Atlanta, Georgia, Mr Roy came to Dhaka, the city of his birth, in the middle of last month and had been due to soon return home after attending the university book fair

US State Department spokeswoman Jen Psaki called the murder 'a shocking act of violence' that was 'horrific in its brutality and cowardice'

Mr Roy, who was also a bio-engineer, had been receiving death threats online for years

Dozens of mourners queue to pay their last respects to Mr Roy at Dhaka University

Police have expressed shock that extremists struck at a university book fair, which was heavily guarded.

Witnesses have even said officers and bystanders were there during the murder - but did nothing.

U.S. State Department spokeswoman Jen Psaki called it 'a shocking act of violence' that was 'horrific in its brutality and cowardice'.

Jodie Ginsberg, chief executive of free speech campaign group Index on Censorship said: 'Our sympathies are with the family of Avijit Roy.

'Roy was targeted simply for expressing his own beliefs and we are appalled by his death and condemn all such killings.'

Mr Roy was a family man and is pictured above with his wife in a photo believed to show their daughter, right, a student at a US college

In 2013, religious extremists targeted several secular bloggers who had demanded capital punishment for Islamist leaders convicted of war crimes during Bangladesh's war for independence.

Blogger Ahmed Rajib Haider was killed that year in a similar attack near his home in Dhaka after he led one such protest demanding capital punishment.

In 2004, Humayun Azad, a secular writer and professor at Dhaka University, was also attacked by militants while returning home from a Dhaka book fair. He later died in Germany while undergoing treatment.