Nigeria's secret police said 21 detainees died while trying to escape its headquarters, with unconfirmed reports that Boko Haram militants were involved.
A security breach at the facility in Abuja, particularly by the feared Islamists, would be an embarrassment for the government and raise new questions about its ability to tackle the extremists.
But there was no official confirmation of the involvement of the group, which has been waging a violent insurgency in Nigeria's northeast this year.
Marilyn Ogar, a spokeswoman for the Department of State Services, said only that detainees had died during the attempt on Sunday.
"Three other detainees who sustained gunshot injuries during the incident have also died," she said.
The incident happened at 7.15am when an officer went to give the detainees food.
"One of the suspects attempted to disarm him by hitting him at the back of his head with his handcuff," the spokeswoman said.
"His attempt to escape drew the attention of other guards at the facility who fired some shots to warn and deter others."
Roads leading to the compound were cordoned off "to prevent possible assistance from external collaborators".
The attempted breakout, especially if Boko Haram suspects were involved, will do little to instil confidence in the government's security operations.
The government has previously been criticised for relying too heavily on conventional military means to tackling an enemy fighting a guerilla war.
Nigeria's military also denied claims from Amnesty International that its troops may have committed war crimes and crimes against humanity in the fight against Boko Haram.
The human rights group has called on the international community to push for an independent investigation into alleged abuses after a bloody three months that have left more than 1,500 dead.
In particular, Amnesty alleged that hundreds of suspected militants were summarily executed after escaping from a detention facility at the Giwa barracks in the northeast city of Maiduguri on March 14.