DHAKA, Bangladesh — When the steamy, clamorous evening had settled over this city, and Oyasiqur Rhaman had finished his day’s work at a travel agency, he would turn to one of his favorite pastimes: Poking fun at fundamentalist Islam.

Mr. Rhaman, 27, blogged under the name Kutshit Hasher Chhana, or the Ugly Duckling, and he specialized in sharp-edged satire. In one post, he adopted the persona of a self-important believer fielding questions from an atheist. (An example: “See, the captive women, impressed at the heroism of the Muslim fighters, used to engage in sex with them willingly. Don’t you see that it gave pleasures to them as well?”) He posted photos of sausages wrapped in pastries, labeled “pigs in a burqa.”

On Monday morning, after he left home for the travel agency, Mr. Rhaman was killed for what he had posted. Three young men — among them students of madrasas here in the capital and in Chittagong — surrounded him and sliced at his head with machetes, cutting deep gouges into his forehead, face and throat. His body was left on the pavement in a pool of congealing blood.

Two men were captured by local residents and handed over to the police, according to Mohammad Salahuddin, who heads the district police station. Those men said an acquaintance known as Masum had instructed them to kill Mr. Rhaman because “he made some comments against Islam” on social media, but that they had not read the comments themselves.