30 people in Maiduguri on Saturday, residents and officials said.
The explosion killed people who were prostrating themselves for afternoon prayers outside the mosque, including traders from the nearby crowded marketplace, survivors said.
Trader Ali Bakomi said the bomber was pushing a wheelbarrow and pretending to be an itinerant trader when he joined them.
Borno state Governor Kashim Shettima toured the scene where one wall was reduced to rubble and another was splattered with blood. Officials told him the bomber killed himself and 16 other people.
Earlier Saturday, rocket-propelled grenades killed at least 13 others in the city and injured more, according to resident Idrissa Mandara. Such grenades are a new tactic that has brought terror to the city that is the birthplace of Boko Haram.
Mari Madu, another resident, said he counted 40 thunderous blasts that began around 1 a.m. before he lost count.
"Each time they fired into the town, we saw bright sparkling flashes which moved with great speed ... One of the blasts shook my roof so badly that I thought it must have landed on my house," he said.
Several homes were destroyed in the suburb Dala-Lawanti, about 20 kilometers west of the city center, he said.
He counted 13 people killed in his compound: six men, five children and two women.
An intelligence officer said Boko Haram was firing the rocket-propelled grenades. Soldiers fired heavy assault rifles in response, said the officer, who insisted on anonymity because he is not supposed to give information to journalists.
Civilian self-defense fighters patrolled until dawn to ensure the Islamic extremists did not get through barriers of sandbags and trenches, said one of the fighters, Abbas Gava.
The nearly 6-year-old Islamic uprising in northeastern Nigeria has killed an estimated 13,000 people. Maiduguri's population of 2 million has swelled with hundreds of thousands of refugees who have been forced from their homes.
A multinational offensive this year forced the insurgents from towns where they had declared an Islamic caliphate but suicide bombings and hit-and-run attacks continue.
On Friday, twin explosions at a village wedding venue killed seven people.
Nigeria's military says Boko Haram's main fighting force is trapped in the Sambisa Forest. But the insurgents keep attacking Maiduguri, which is 200 kilometers away.
At his inauguration Friday, Nigeria's new President Muhammadu Buhari vowed to crush the extremists. Buhari said he will move the headquarters for the war against Boko Haram from Abuja, the capital in central Nigeria, to Maiduguri.