The Nigerian army has imposed a dusk-to-dawn curfew on the northeastern town of Maiduguri in the aftermath of a Boko Haram attack on the city, the military has said in a statement.

"In view of the recent development within Maiduguri metropolis a 24-hour curfew is hereby imposed in the city," Colonel Tanko Gusau, Nigeria's army spokesman, said in the statement on Thursday. 

"This is done to protect lives and properties of innocent and law-abiding people of Maiduguri," the statement read.

Boko Haram fighters launched an attack on the city but were repelled by Nigerian troops after intense clashes, residents and the army said. Sources told the AFP news agency at least three soldiers, six vigilantes and dozens of Boko Haram fighters were killed in the clashes that ensued in the city.

"The terrorists suffered serious casualties," he said, without specifying a figure, adding that 12 vigilantes were injured by the shrapnel of the detonated bombs.

Dozens of rebels armed with heavy guns and rocket-propelled grenades stormed the northern outskirts of the city near Giwa military base, shooting and firing explosives indiscriminately, local witnesses told the AFP agency. 

The army said its soldiers had fought off "a band of terrorists" and that two bombs carried by female suicide bombers were detonated ahead of the attack.

The assault was the first on Maiduguri after a three-month lull following sweeping offensives on Boko Haram strongholds by a regional coalition of troops from Nigeria, Niger, Chad and Cameroon.

Sources said the assailants had made attempts to overrun a military facility, the 21 armoured brigade, which was attacked last March 14.

Civilian vigilantes

The army said that the situation was now under control. A member of the civilian vigilantes assisting the
Nigerian military in the fight against Boko Haram said the attack could have been a reprisal for the losses incurred by the rebel group in a Tuesday offensive on their camp some 40 km outside the city.

"The attack was from all indication in response to the huge casualties Boko Haram suffered yesterday in the military operation on their camp in Mafa area in which some women and children were rescued," said the vigilante who asked not to be named.

Boko Haram claimed an area larger than Belgium last year and was fast becoming a regional threat after it increased cross-border incursions.

Chadian and Nigerian troops entered the offensive earlier this year and drove the fighters out of some key Borno towns. Cameroonian forces pushed them out of its border areas.

The Nigerian military has since launched a ground offensive on the group's last stronghold, in the Sambisa forest reserve.

Boko Haram, designated by the US as a "terrorist" organisation, has been fighting since 2009 to establish sharia law in all 36 states of Nigeria, which is roughly equally divided between a mainly Christian south and a largely Muslim north.