Authorities in Borno state say gunmen stormed the prison and killed two guards early Friday, allowing an unknown number of prisoners to escape. Police spokesman Samuel Tizhe said 23 prisoners have since been recaptured.
Boko Haram radicals have been blamed for dozens of increasingly violent attacks across the northern part of the country.
Some Nigerians suspect the group might also have been involved in a brutal cattle raid earlier this week that left 34 people dead.
Witnesses say the attack followed an earlier incident where the gang sought to rob traders at the market. One of the robbers was caught while trying to escape and burned to death.
The gunmen returned later that night shooting indiscriminately at the market and throwing explosives.