Police said the attack late Wednesday on Samad, a master's student at Jagannath University, was planned.
"He was on his way back home from his evening classes when he was circled by a group of three to four people," said Senior Assistant Police Commissioner Nurul Amin of the Dhaka Police.
Police said the attackers then fled the scene on motorcycles. No arrests have been made.
Bangladeshi students took to the streets to protest against the brutal killing.
The killing is certain to add to fears among intellectuals and writers who have challenged religious thought in Bangladesh, a majority Muslim country with a sizable Hindu religious minority.
The constitution in Bangladesh defines Islam as the state religion. But it also includes a clause promising to defend the "principle of secularism."
Bangladesh Home Minister Asaduzzaman Khan pledged to bring the killer to justice but also said that no-one had the right to attack religious leaders in the country.
"Why are they using these kind of languages against religious establishment? In our country, we do not allow these kind of languages. It is restricted by our law," he told CNN.
"No one has the right to attack religious leaders -- be it Prophet Mohammad, Guru Nanak or Jesus."
Imran Sarker, who leads a blogging and online activist network in Bangladesh, described Samad as a "very active secular activist."
"He was very vocal on issues of religious fundamentalism, war crimes, minority issues, corruption and injustice against women," Sarker said.
"He used to regularly post notes on Facebook expressing his views."
Friends and supporters took to social media to express their grief and pay tribute to Samad.
"Rest in Power, Nazimuddin Samad," one Facebook post said. "There is no end to this brutality."
On Twitter, U.N. Special Rapporteur Karima Bennoune said extremism "is a human rights issue."
Mukto Mona, an English and Bangladeshi website that frequently challenges and criticizes religious beliefs, added its voice to the tributes.
"Nazimuddin was a courageous freethinker; he was vocal in his support for a secular and humane Bangladesh," the post reads.
Victim had 'gone into hiding'
"This is terribly shocking," said Gulam Rabbi Chowdhury, a childhood friend and former high school classmate of Samad. Chowdhury said Samad went into hiding for several months last year because he feared for his life.
Mukto Mona posted excerpts of an exchange between writers who expressed concern for Samad's safety.
"I am also scared ... scared of getting killed," Samad responded in writing, according to a post published on Mukto Mona.
"But what else can I do? It's better to die rather than living by keeping my head down."
Mukto Mona's founder, a U.S.-based Bangladeshi writer named Avijit Roy, was killed by machete wielding attackers outside an annual book fair in Dhaka in February 2015.
Press freedom groups have been sounding the alarm about the campaign of violence against writers in Bangladesh.
"One by one, extremists are silencing these voices, while the government looks on," the Committee to Protect Journalists said on Twitter.
"Bangladesh has been ravaged by a spate of bloody attacks on bloggers and other writers who espouse secular viewpoints," said Karin Deutsch Karlekar, director of freedom of expression programs at PEN America.
The group urged the U.S. government and other countries to provide shelter to writers at risk of being attacked.
U.S. State Department spokesman Mark Toner called Samad's slaying "barbaric" and said the United States would keep supporting Bangladesh's government in efforts to fight terrorism and counter violent extremism.
Asked whether the United States would provide refuge to Bangladeshi writers who have been threatened, Toner said he'd look into the matter
"My understanding is that for a select number of bloggers who continue to be under imminent danger, that is one option that's under consideration," he said. "I don't know, I'll have to see if ... there are individuals who are taking advantage of that."