Streets are deserted with markets, schools and hospitals shut in the densely populated city, reports say.
The army said the lockdown was ordered to protect lives and property.
Troops and vigilantes fought off the militants on Tuesday evening as they tried to enter Maiduguri, residents told the BBC.
This was their most serious attempt to enter the city since the military declared in March that it had recaptured all urban areas from Boko Haram, says BBC Nigeria analyst Aliyu Tanko.
Boko Haram is linked to Islamic State, which is fighting for a global caliphate.
Maiduguri, a city of about two million people, is Boko Haram's former headquarters.
Pro-military vigilante leader Yusuf Sani told AFP news agency that six of his men were killed and 12 others were wounded when three female suicide bombers detonated their devices.
"The terrorists suffered serious casualties," he added.
An army statement said the curfew would remain in force for 24 hours and the "situation is firmly under control".
Why Boko Haram remains a threat
Boko Haram: What next for the rescued?
Jihadist groups around the world
Nigeria's military has imposed a curfew in the main north-eastern city of Maiduguri after a surprise attack by militant Islamist group Boko Haram.