At least six naval personnel were seriously wounded in explosions at the end of prayers on Friday at a mosque inside a Bangladesh naval base in Chittagong, police said.
Two people were arrested in connection with the blasts. Police said they had confessed to being members of banned militant group Jama'atul Mujahideen Bangladesh.
The group wants to establish a sharia-based Islamic state in Bangladesh and tends to target government facilities.
"Two bombs blasted at the mosque after Jumma prayer and six persons were critically injured," said Devdas Bhattachariya, an additional commissioner of Chittagong Metropolitan Police, adding that all the wounded were from the navy.
No one from the navy was available for comment.
Security forces also deactivated five unexploded bombs from the mosque in the port city of Chittagong, some 265 km (165 miles) southeast of Dhaka.
It is the first time a mosque used by Bangladesh's Sunni Muslim majority has been attacked.
Last month, a Shi'ite Muslim mosque in Bangladesh's northern district of Bogra was attacked, killing a cleric and wounding three other people in the second attack on the tiny Shi'ite Muslim community in a month.
Islamic State claimed responsibility for those attacks, although the government denies any Islamic State presence in the country.
Islamic State also claimed responsibility for the killings of a Japanese citizen and an Italian in the past months, but police blamed those killings on Jama'atul Mujahideen Bangladesh.
Bangladesh is planning to join a coalition led by Saudi Arabia of Islamic countries fighting militants.