Boko Haram, the militant group that has killed tens of thousands of people and displaced millions in the region, is thought to be behind the attack in Mubi, a town in Adamawa state, but has not yet claimed it.
The group has used children as young as five to carry out hundreds of attacks on busy marketplaces, checkpoints and mosques in the past few years, but the death toll from the Medina mosque is among the highest.
Pictures posted on social media in the aftermath of the attack showed bloodstains on the floor of the mosque, which had a gaping hole in its wall.
Abubakar Sule, who lives near the mosque, told Agence France-Presse he had just returned home when he heard the blast and rushed back to the scene.
“I was there when the rescue was on and 40 people died on the spot and several others were taken to hospital with severe and life-threatening injuries,” he said.
“The roof was blown off. People near the mosque said the prayer was mid-way when the bomber, who was obviously in the congregation, detonated his explosives.”
A police spokesman, Othman Abubakar, said authorities were “still trying to ascertain the number of injured because they are in various hospitals”.
Asked who was responsible, Abubakar said: “We all know the trend. We don’t suspect anyone specifically but we know those behind such kind of attacks.”
Boko Haram is most infamous for the abduction of hundreds of schoolgirls three years ago from their dormitory. Many of the Chibok girls, whose cause was made famous by Michelle Obama and other celebrities, have been released, but more than 100 remain missing.
Pushed back from some of its former strongholds, Boko Haram’s main tactic is now bombing.
Some bombers kill a handful of people; others hand themselves in to the authorities, who remove their and have their explosive vests.
There is little that can be done to stop the attacks and girls and young women walking alone are frequently suspected of carrying bombs under their clothes.
This year, the Guardian interviewed vigilantes who described the “hugging technique” they had developed in response: young men take turns to keep an eye on busy neighbourhoods, and if they see somebody who seems suspicious, they run up to them and hug them to limit the damage should they detonate.
The Nigerian military has repeatedly claimed to have won the war against Boko Haram and to have killed its most prominent leader, Abubakar Shekau. But President Muhammadu Buhari’s claim late last year that the extremist group had been “crushed” has proven to be premature.
Boko Haram has been blamed for more than 20,000 deaths during its nearly decade-old insurgency, which has spilled over into neighbouring countries and displaced millions of people, creating a vast humanitarian crisis.
Boko Haram briefly overran Mubi in late 2014 as its fighters rampaged across north-eastern Nigeria, seizing towns and villages in its quest to establish a hardline Islamic state.
The town’s name was changed temporarily to Madinatul Islam, or “City of Islam” in Arabic, during the Boko Haram occupation.
But it has been peaceful since the military and the civilian militia ousted the terrorists from the town, which is a commercial hub and home to the Adamawa State University.
In recent months, Boko Haram activity has been concentrated on the far north of Adamawa state, around Madagali, which is near the border with Borno state.
This month, at least two civilians were killed when dozens of Boko Haram fighters tried to storm the town of Gulak but were repelled by soldiers.
There have been repeated suicide bombings in the area, which is near to the Sambisa forest area of Borno, where the militants had a base.
Boko Haram fighters are also said to be hiding in the Mandara mountains, to the east of Adamawa state, which forms the border with neighbouring Cameroon.