Boko Haram fighters attacked the city of Damaturu in north-east Nigeria on Tuesday, after the country's military evacuated thousands of people from a nearby village in preparation for an offensive.
Two residents of the Yobe state capital said Boko Haram fighters were behind the assault, the first time the extremists have attacked the city since 2014.
"Residents and businesses all closed as we fled into the city to avoid being caught up in the attack. While fleeing, I saw truckloads of soldiers heading to Maisandari," said Adamu Sani, a trader in the city's Maisandari area.
Civil servant Hashimu Idris said: "We pray the soldiers push them back, otherwise it will be another disaster in the city."
Militants loyal to the faction led by Abubakar Shekau launched a dawn raid on Damaturu on December 1, 2014, killing more than 150 people, including 38 police officers.
That followed a bomb attack on June 18 that year which killed about 21 people watching a World Cup match, while 30 people were killed in the city in an attack on police buildings in October 2013.
Nigerian forces evacuated about 2,000 people from Jakana village, 90 kilometres from Damaturu, in the neighbouring Borno state.
They were escorted to the Bakassi camp for internally displaced people in Maiduguri, the National Emergency Management Agency said.
NEMA north-east coordinator Abulkadir Ibrahim said the move was a result of efforts to flush out Boko Haram fighters in the area.
Jakana residents said they were given no notice but to leave their homes. One of them, Modu Kaka, said: "The soldiers came this morning and told us to assemble and began herding us into trucks. We left all our possessions in Jakana and we are now dependent on food aid."
Bakassi is one of several camps that house tens of thousands of displaced people. They live in poor conditions and rely on aid agencies to distribute food.
A military official said the evacuation was in preparation for a "big operation" against the ISIS-linked faction of Boko Haram.
Jakana lies on a route used by militants to move between their camps in the Benisheikh forest area of Borno and their hideouts in the Buni Yadi area of Yobe.
In January, Boko Haram fighters sent letters to Jakana and Mainok residents telling them to leave their homes before a raid on military forces.
Coalition forces from Nigeria, Chad and Cameroon have in the past few weeks launched intensive air and ground offensives against militant camps in Lake Chad, according to military sources and militia groups.
Boko Haram's decade-long insurgency has killed more than 27,000 people in north-eastern Nigeria, with 1.8 million displaced from their homes.