A suicide bomber blew himself up on Sunday among young Iraqis assembled in a cafe in Moqdadiyah, northeast of Baghdad, killing at least seven people, police said.
The Islamic State (IS) group, which swept through large parts of Iraq two years ago but no longer holds fixed positions in Diyala province where Moqdadiyah is located, said it carried out the attack.
"It was a place where young people were gathered... for now we have seven killed and 22 wounded," a police colonel in Moqdadiyah told AFP.
A hospital official in Moqdadiyah, 80 kilometres (50 miles) northeast of the capital, confirmed the casualty toll.
"Abu Ifan al-Moslawi, may God accept him, was able to... blow up his explosive belt," IS group said in a statement published on social media, adding that the blast had left 30 dead and wounded.
The interior ministry said the explosion occurred in a market area.
The attack happened despite the bomber's picture being put up at checkpoints all over town after his mother tipped off the security services, the ministry also said in a statement.
Moqdadiyah is in the religiously and ethnically mixed province of Diyala, which the government declared free of IS in January 2015 but which has continued to see suicide and car bomb blasts since.
IS claimed an attack on May 13 on a cafe packed with supporters of Real Madrid football club in the town of Balad that killed 16 people.