Villagers in an area of Nigeria where Boko Haram operates have killed and detained scores of fighters who were suspected of planning a fresh attack, the residents and a security official said.

Locals in Nigeria's northern states have been forming vigilante groups in various areas to resist the armed group which has held more than 270 schoolgirls captive since last month.

In Kalabalge, a village about 250km from the Borno state capital of Maiduguri, residents said they were taking matters into their own hands because the Nigerian military was perceived as not doing enough to stem Boko Haram attacks.

On Tuesday morning, after learning about an impending attack by fighters, locals ambushed two trucks with gunmen, according to local officials.

At least 41 fighters were killed in the attack, officials, who spoke to Al Jazeera on conditions of anonymity, said

RELATED: The challenge of reporting on Boko Haram

The AP news agency was told that at least 10 armed men were detained. It was not immediately clear where the detainees were being held.

Kalabalge trader Ajid Musa said that after residents organised the vigilante group, "it is impossible" for fighters to successfully stage attacks there.

"That is why most attacks by the Boko Haram on our village continued [to] fail because they cannot come in here and start shooting and killing people," he said.

US support

Borno is where more than 300 girls were abducted last month and one of three Nigerian states where President Goodluck Jonathan has imposed a state of emergency, giving the military special powers to fight self-declared jihadist groups, whose stronghold is in northeast Nigeria.

Britain and the US are now actively involved in the effort to rescue the missing girls.

Boko Haram's long reign of violence

US Attorney General Eric Holder said FBI agents and a hostage negotiating team were in Nigeria now, providing technology and other materials. US reconnaissance aircraft were flying over Nigeria in search of the missing girls.

Boko Haram kidnapped the girls on April 15 from a school in Chibok. At least 276 of them are still held captive, with the group's leader threatening to sell them into slavery.

In a video released on Monday, he offered to release the girls in exchange for the freedom of jailed Boko Haram members.

A Nigerian government official has said "all options" are now open - including negotiations or a possible military operation with foreign help.

Boko Haram has killed more than 1,500 people this year.