However, the military told the BBC only three people had been killed.
At least 23 others have been killed in separate attacks in the north this week blamed on militants wanting to impose Islamic law on Nigeria.
The insurgency was launched by Boko Haram in Maiduguri in 2009, but a second militant group, Ansaru, emerged last year.
Last month, suspected militants slit the throats of at least 15 Christians near Maiduguri.
In the latest attack, the assailants first beheaded a father and son at their home, before beheading two other men at their residence and a fifth person at another house in Maiduguri, said a resident, who spoke to the BBC Hausa service on condition of anonymity.
It is unclear who carried out the attacks or what their motives were, but there are strong suspicions that Boko Haram was involved, the resident said.
Two gunmen lost their lives and a soldier was wounded during an exchange of fire”
A Maiduguri-based journalist confirmed the resident’s account to the BBC.
But army spokesman Lt-Col Sagir Musa said suspected gunmen killed three people during the attack.
The joint task force – made up of soldiers and policemen – rushed to the scene when it was alerted, he said.
“It cordoned off the area, arrested three suspects and recovered one assault rifle with ten rounds of ammunition,” Lt-Col Musa said.
On Monday, gunmen apparently targeted hunters selling bush meat in Damboa in north-east Nigeria, killing 18 people, witnesses said.
Another five people died on Tuesday when a group of men playing draughts was attacked in Kano.