Boko Haram gunmen attacked a Nigerian military base and adjacent police barracks in the northeastern town of Buni Yadi, killing 31 security personnel, security sources and witnesses said.
The attack late on Monday in Yobe state occurred not far from where the Islamist insurgents shot or burned to death 59 pupils at a boarding school in February.
The militants, whose violent struggle for an Islamic state in northern Nigeria has killed thousands and made them the biggest threat to security in Africa's top oil-producing state, are still holding more than 200 girls kidnapped on April 14, an act which provoked international outrage.
Yobe police spokesman Nansak Chegwam said he was aware of the attack but could provide no further details.
A resident of Buni Yadi, who identified himself only as Mustafa for fear of retribution, said the militants arrived in an armoured personnel carrier and six Toyota pickup trucks before dismounting and firing into the air.
They fired rocket propelled grenades at both bases. A senior security source in Yobe state said 17 soldiers were killed and 14 police officers also died.
In what has become rare for a movement that has killed thousands of civilians in the past year, Boko Haram called out to people on the street not to run away as they had only come for the security forces, Mustafa and the security source said.
The insurgents also razed the police barracks, the army base, the high court and residence of district head Abba Hassan.
"One was shouting in English to the others: 'Let's go, let's go. Finish this and let's go'," a policeman who escaped the attack and fled to the state capital Damturu said.
HUNT FOR GIRLS
From being a religious movement opposed to Western culture - Boko Haram means "Western education is a sin" in the northern Hausa language - the sect has emerged as a well armed, fully fledged insurrection.
A military offensive launched a year ago against Boko Haram, which initially seemed to be working, appears to have left the group stronger than ever. The insurgents occupy a vast, hilly terrain along the border with Cameroon, from where they have repeatedly launched devastating hit and run strikes.
Nigeria and its neighbours say Boko Haram now threatens the security of the whole region.
Cameroon has deployed armoured vehicles and some 1,000 troops to its border region with Nigeria to counter the rising threat.
Chief of Defence Staff Air Marshal Alex Badeh said on Tuesday the military knew where the abducted girls were but ruled out using force to rescue them for fear of endangering their lives.
On Tuesday the United States said it did not have independent information to confirm Nigeria's claim to know the whereabouts of kidnapped girls.
Since the girls were captured, according to a Reuters count, at least 470 civilians have been killed in various locations at the hands of Boko Haram, which has said it wants to reinstate a medieval Islamic caliphate in Africa's most populous nation.
Nigeria accepted help from the United States, Britain, France and China last week and around 80 U.S. troops have arrived in neighbouring Chad to start a mission to try to free the girls. Surveillance drones are scanning the Sambisa forest, where parents say the girls were last sighted.