Samidul Islam, aged around 30, was working at a security checkpost in the Cantonment area when he was attacked.
Witnesses said a man of the same age as Samidul's crossed over from the other side of the road and swooped on the military policeman with a machete.
Samidul was severely wounded in the attack, which left injury marks on his right neck, left cheek, hand and fingers, the Dailystar reported. He has been admitted to hospital.
The attacker, when chased by locals, had entered a five-storeyed building in an attempt to escape. He was later arrested, police said.
Also Read
On November 4, a group of unknown assailants on motorbikes had attacked a checkpost on the outskirts of Dhaka and hacked to death the constable on duty with sharp weapons. It was the second such attack in less than a month.
In a web post, monitoring group SITE said it has tracked the Islamic State's post claiming the attack.
Prime Minister Sheikh Hasina has said that a campaign was underway to portray Bangladesh as "unsafe" and pave the way for foreign intervention.
"A propaganda is there about the presence of the Islamic State or al-Qaeda in Bangladesh... It is being done to create a notion that Bangladesh is unsafe," Hasina has said.
"Could I ask the people to ponder what will happen if it is established- the (foreign) Islamists presence in Bangladesh ... What is happening in Syria, Iraq and Afghanistan."