Police in Bangladesh have arrested a suspected Islamist militant over the hacking death of a US blogger whose writings on religion angered hardliners.

Deputy police commissioner Masudur Rahman said the man, who was named as 24-year-old Arafat Rahman, was being held in connection with the 2015 machete attack on Avijit Roy and his wife. Mr Roy was fatally injured and his wife seriously hurt, on their way home from a book fair in Dhaka.

Police said they believed the suspect was a member of the Al-Qaeda-inspired group, Ansarullah Bangla Team. The organisation has been blamed for numerous attacks, including a July 2016 assault on a restaurant in the city’s diplomatic quarter that left 22 people dead, most of them foreigners.

Reuters said police revealed they had arrested the suspect after analysing CCTV footage. They said he was detained by officers of the counterterrorism police unit on the outskirts of the capital on Friday night.

“In the primary interrogation, he confessed his involvement in the killing of four other secular activists,” said Mr Rahman, the senior police officer.

The killing of Mr Roy, an atheist US citizen of Bangladeshi origin, sent shockwaves across the country and underscored the threat of Islamist extremists in the Muslim-majority nation of 160 million people.

Bangladesh cafe attack suspect killed in police raid

It was one of a series of deadly attacks targeting bloggers, foreigners and religious minorities.

The news agency said police believe the Ansarullah Bangla Team militant group is behind the murders of more than a dozen secular bloggers and LGBTQ-rights activists. They believe a sacked army major, who is still at large, was the leader of the group and masterminded the killings.

In pictures: Bangladesh attacks Show all 10 1 /10 In pictures: Bangladesh attacks In pictures: Bangladesh attacks Bangladesh attacks Hindu ashram worker Nityaranjan Pande, 62, was hacked to death in Pabna on 10 June 2016 AP In pictures: Bangladesh attacks Bangladesh attacks Hindu priest Anando Gopal Ganguly, left, was murdered in Jhenidah in Bangladesh on 7 June 2016 EPA In pictures: Bangladesh attacks Bangladesh attacks Mahmuda Khanam Mitu, wife of the Deputy Commissioner of Chittagong Metropolitan Police, was murdered in Chittagong, Bangladesh on 5 June 2016 EPA In pictures: Bangladesh attacks Bangladesh attacks Bangladesh Students Union arranged a torch procession in protest over recent murders of free thinkers in Dhaka NurPhoto In pictures: Bangladesh attacks Bangladesh attacks Murdered gay rights activist Xulhaz Mannan, who was editor at Bangladesh’s only LGBT magazine Rex In pictures: Bangladesh attacks Bangladesh attacks A Bangladeshi policeman stands guard at the site of the murder of a law student, hacked to death by four assailants the night before, in Dhaka on April 7, 2016 AFP/Getty In pictures: Bangladesh attacks Bangladesh attacks People have protested against the murders around the world, seen here in Kolkata AFP/Getty Images In pictures: Bangladesh attacks Bangladesh attacks A relative of dead Bangladeshi blogger Washiqur Rahman reacts after seeing his body at Dhaka Medical College in Dhaka on March 30 AFP/Getty Images In pictures: Bangladesh attacks Bangladesh attacks People gather on the spot where Bangladeshi blogger Avijit Roy was killed in a street in Dhaka (EPA) EPA In pictures: Bangladesh attacks Bangladesh attacks Bangladeshi social activists shout slogans during a protest against the killing Avijit Roy in Dhaka on February 27, 2015 AFP/Getty Images

Al-Qaeda and Isis have also claimed responsibility for a series of killings over the past few years, including that of Mr Roy, whose killing was marked by protests by hundreds of people who took to the streets to mourn his death.

At the time of his murder, his family said he had received threats following the publication of articles promoting secular views, science and social issues on his Bengali-language blog, Mukto-mona, or Free Mind.

He defended atheism in a Facebook post, calling it a “rational concept to oppose any unscientific and irrational belief”.

The government has denied the presence of foreign extremist groups, choosing to blame domestic militants instead. But security experts say the scale and sophistication of the 2016 café attack suggested links to a wider network. Police and army commandos have killed more than 60 suspected militants and arrested hundreds since that incident.