Fifty-five people have been killed in the north-east of Nigeria in co-ordinated attacks by the Boko Haram militant group, the Nigerian army says.
It said 105 prisoners were freed in the pre-dawn raid in Bama, Borno state.
Bama's police station, military barracks and government buildings were burned to the ground, said the military and witnesses.
Correspondents say extremist attacks are common in the region but the scale of bloodshed makes this raid stand out.
This strike - coming on the back of other deadly attacks - undermines the suggestion that the military operation against the militants has diminished the threat they pose, says the BBC's Will Ross in Lagos.
President Goodluck Jonathan has set up a committee to agree the terms of an amnesty for the rebels but Boko Haram's leader, Abubakar Shekau, has so far rejected the idea.
Tuesday's raid in the remote town began when some 200 heavily-armed suspected members of Boko Haram arrived in buses and pick-up trucks at about 05:00 (04:00 GMT), said Musa Sagir, a military spokesman based in Maiduguri, some 70km (44 miles) from Bama.
"Some of the gunmen attacked the military barracks but they were repelled. Ten of them were killed and two were arrested," he told AFP news agency.
"But the gunmen broke into the prison, freeing 105 inmates, and killed all prison warders they could see except those who hid in a store where cooking utensils were kept," he said.
Some of the attackers wore army uniforms for the assault, which continued for almost five hours, he added.
Twenty-two police officers, 14 prison wardens, two soldiers and four civilians are said to have died along with 13 members of Boko Haram.
Bama police commander Abubakar Sagir was quoted as saying the civilians comprised a woman and three children.
Police and public buildings - reportedly including a magistrate's court - were razed to the ground.
"The call to prayer was just being said at about 05:00 when the Boko Haram started shooting from all directions and we ran for our lives," a witness, Amina Usman, told Reuters.
"One woman who could not run burned to death," Ms Usman added.
Boko Haram, as it is popularly known, has its roots in this region of Nigeria. It is fighting to overthrow the government and set up an Islamic state.
Late last month the military launched a raid to hunt down militants in Baga, also in Borno state, after Boko Haram militants attacked a military patrol.
Nearly 200 people died in the raid, and thousands of buildings were destroyed, leading to claims by rights groups that the military had used excessive force. The army put the number killed at 37.