Gunmen shot at traders and customers as they raided the busy market for food supplies on Friday.
The number of casualties is not yet clear, with some reports suggesting as many as 30 people were killed.
Basically surrounding Maiduguri, the capital of Borno State.
Authorities have struggled to defeat the militant Islamist group, which has been waging an insurgency in Nigeria since 2009.
The BBC's Will Ross, in Lagos, warns that parts of north-eastern Nigeria are slipping further and further out of the government's control, creating a growing humanitarian crisis.
Many residents fled Mainok after the attack, making it difficult to obtain accurate information.
Reuters news agency quotes two security sources as saying that at least 36 people, including 13 gunmen, were killed in the gun battle, which continued into Saturday.
"Thirteen of the terrorists... were killed, some of them fled with gunshots and our colleagues are already on their trail. Unfortunately, 23 civilians died in the attack," one source is quoted as saying.
|A screengrab of Boko Haram leader Abubakar Shekau (C) sitting flanked by militants|
The militants are well-armed and often wear military uniforms
I don't understand something (I know, you're not surprised), but Boko Haram does a lot of their massacres in the daytime. Why can't they be seen travelling? Why doesn't the military have several drones flying all around Borno State looking for small convoys?
They could, at least, have time to warn a town of their coming, and perhaps even fly some paratroopers into the attack zone. They could even drop some on the road the militants took to enter the town, and ambush them on their way back.
Oh! I forgot! All the money for the military has been pilfered. And, officers are much better at pilfering than actual military work. Nevermind.
One resident said that some of those running for safety were killed after being hit by cars speeding away from the area.
He said that many soldiers and civilians ran away into the bush.
Mainok is located some 56 km (35 miles) outside of Maiduguri, the capital of Borno state.
In May 2013, President Goodluck Jonathan imposed a state of emergency in the northern states of Borno, Yobe and Adamawa, vowing to crush the Islamist insurgency.
|A woman and her children who fled their home following an attack by |
Islamist militants in Bama take refuge at a school in Maiduguri, Nigeria
Thousands of people are displaced every week
It frequently attacks schools and colleges, which it sees as a symbol of Western culture, and was behind the kidnapping of over 200 schoolgirls from Chibok in Borno state.
Earlier this week gunmen stormed a teacher training college in the northern city of Kano in a suspected Boko Haram attack, killing at least 14 people.
The New York-based Human Rights Watch says more than 2,000 civilians have been killed this year.