Boko Haram fighters who launched an attack on northeast Nigeria's largest city of Maiduguri have been repelled by Nigerian troops after intense clashes, residents and the army have said.

Dozens of fighters 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 news agency.

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

There was no immediate information on any casualties.

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.

"They came in through the Kayamla area around 6:30pm [17:30 GMT] when residents were preparing for evening prayers, firing in all directions and hurling bombs," said local resident Ibrahim Sidi.

"Soldiers from Giwa barracks deployed and intercepted them just on the outskirts of the city and engaged them in a fight that lasted for over 40 minutes."

Hajara Musa was among hundreds of residents of Fori neighbourhood who sought refuge in a nearby university campus to escape the clashes.

"Bullets were flying all over the place, we had to crouch and move on all fours as bullets whizzed overhead," Musa said.

'Terrifying'

Bilkisu Ahmad, a student at the Maiduguri University said they were ordered by the campus security guards to lay flat to avoid being hit by bullets and grenades.

"It was terrifying," Ahmad said.

After the fighters were forced to withdraw, some residents were able to return to their homes.

"Some of us have moved back to our homes after soldiers neutralised the attack but many others have fled into the city," Musa added.

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 Boko Haram in a Tuesday offensive on their camp some 40km 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.