The incident occurred in the town of Mubi in Adamawa State at 1 p.m. local time as worshippers gathered for afternoon prayers, police said.
A spokesman for the Adamawa State police said the bombers were positioned in different locations around the mosque.
"The first bomber went into the mosque while they were praying and detonated his explosives, killing four people," Othman Abubakar said.
As worshippers fled the mosque, the second bomber, who was a few hundred meters away, also detonated his device, killing another 20 people, Abubakar said.
"This desecration of a place of worship by criminals is tragic and condemnable," said a five-part statement on the verified Twitter account for Nigerian President Muhammadu Buhari's office.
Vice President Yemi Osinbajo was working with emergency services to make sure victims were being cared for, according to the tweets.
The government has ordered security services to bolster their numbers in Mubi and other places, particularly around markets and places of worship.
The bombings come just a day after suicide bombers killed four people in Maiduguri, Borno State.
It also comes a day after Buhari met Trump at the White House and had discussions about the security challenges the country faces, including the nearly decadelong insurgency by Boko Haram terrorists in the northeast of the country.