Suspected members of the Nigerian Islamist sect Boko Haram raided the northeastern town of Bama on Tuesday, leaving 55 people dead, the military said on Tuesday.
Boko Haram gunmen killed 22 police officers, 14 prison officials, two soldiers and four civilians, while 13 of the group's own members died, military spokesman Sagir Musa told Reuters.
Gunmen freed 105 prison members during the raid which began at around 5 a.m. (0400 GMT) and lasted almost five hours, Musa said. Bama's police station, military barracks and government buildings were burned to the ground, a Reuters witness saw.
Bama is a small, remote town in northeastern Borno state, where Boko Haram first launched an uprising in 2009.
The Boko Haram sect and offshoots such as the al Qaeda-linked Ansaru, as well as associated criminal networks, pose the main threat to stability in Africa's top energy producer.
Western governments are increasingly concerned about Nigerian militants linking up with other jihadist groups in the West African region.
Boko Haram wants to carve out an Islamic state in a country split roughly equally between Christians and Muslims. One of its chief demands is that its imprisoned members and family members are released and it has carried out several prison breaks.
Violence in Nigeria's north has shown no signs of letting up. Clashes between Islamists and a multinational force from Nigeria, Niger and Chad killed dozens of people last month.
A senator who visited the site said 228 people were killed, but the military puts the figure at 37.