The attack late yesterday evening 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 Harm 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.