Boko Haram militants have captured a Nigerian army base in the remote town of Baga in the country's northeast, killing several civilians and soldiers in an attack on Saturday, according to reports citing security officials and eyewitnesses.

After the deadly attack, troops abandoned the army base located on the shores of Lake Chad, Al Jazeera reported, citing two sources, who also claimed that the Boko Haram fighters attacked the town using military vehicles. The attack came after suspected Boko Haram gunmen kidnapped 40 young men from the remote village of Malari in the northeast last week. A prolonged offensive by Boko Haram in the country's northeast has tested the Nigerian army's capability to hold its own against the Islamist group.

“We were woken up by heavy gunshots, and we couldn't identify where the shots were coming from,” one of the residents who fled to the neighboring country of Chad, told BBC News. “They came through the north, the west and from the southern part of the town because the eastern part is only water. So, when we [went] towards the western part, we saw heavily armed Boko Haram men coming towards us.”

According to residents who survived the attack, the militants killed several people and set the town on fire. Baga, which was the last town in northern Borno state to be under government control, hosted the military base of the Multi-National Joint Task Force (MNJTF), comprising troops from Niger, Nigeria, Chad and Cameroon. In 2013, Baga was the site of fighting, which killed dozens, between MNJTF troops and Boko Haram.

Residents who escaped to Chad reportedly claimed they decided to flee the town after they saw MNJTF troops running away.

“The soldiers were trying to repel the attack but that wasn't going to happen because a lot of the soldiers were without their guns and some were running into the town,” the resident told BBC News. “When you see soldiers running away into the town - what are you to do, other than to just run away as well?”

In December, a Nigerian court sentenced 54 soldiers to death after they were convicted of mutiny. According to reports, the soldiers allegedly refused to fight Boko Haram in an attempt to recapture three towns taken over by the militant group.

Last week, suspected Boko Haram gunmen raided the northeast village of Malari and abducted about 40 boys and young men, between the ages of 15 and 23. The incident followed another recent attack when at least 11 people were killed after Boko Haram members fired on a bus in Waza, in Cameroon.