Boko Haram bombers have killed at least four civilians after fighting broke out on the outskirts of northeast Nigeria's biggest city, Maiduguri.

Media reports said on Friday that the militants were trying to reach the city's Giwa Barracks, where other militants had been imprisoned, when they were stopped by security forces.

Nigerian police said Thursday’s attack was repelled "after a fierce gun battle" and firing of tear gas. Two officers were injured while seven others were also wounded.

The attack was repelled with the arrival of reinforcements.  Boko Haram terrorists were pushed back to Alidawari area near Maiduguri.

At least one member of security forces was reportedly killed when a bomber detonated his explosives near a military vehicle.

Bashir Garga, a member of the Maiduguri National Emergency Management Agency, said:  "They were innocent citizens, four of them, who died."

The Borno state police gave a lower death toll of two, including a member of the civilian militia assisting the military with security against Boko Haram.

The Nigerian government claims that Boko Haram, which is affiliated to the Daesh Takfiri terrorist group, has been "largely defeated."

Boko Haram rarely attacks urban areas. However, it is believed that more than 100 militants were involved in the attack.

Boko Haram attacks are a direct challenge to President Muhammadu Buhari's declaration that Boko Haram has been "technically" defeated.