DHAKA, Bangladesh — The young man, inching past a crowded checkpoint near a truck stand in Bangladesh’s capital, caught the attention of an alert police officer.

His backpack, together with his appearance, from the unshaven beard to the long Punjabi tunic over baggy pants, set off the suspicion that he was an Islamist militant. The man was arrested after he was found to be carrying a machete, an unregistered pistol and six bullets.

The discovery of the weapons raised alarms. For the last three years, atheist writers, freethinkers, foreigners, religious minorities, gay rights activists and others have been terrorized and killed in Bangladesh by shadowy figures who have struck with machetes and sped off on motorbikes.

Little was known about the attackers, except that they were Islamist radicals, and that their assaults have been coming with ever-greater frequency this year.