A suicide bomber killed at least 41 people, including five children, when he struck at a mosque in northern Afghanistan after Eid al-Adha prayers on Friday, officials said.
Dozens more were wounded as the bomb ripped through the crowd of worshippers in Maymana city in Faryab province and there were fears the death toll could rise.
There was no immediate claim of responsibility, but suicide bombings are a favourite weapon of Taliban Islamists trying to topple the Western-backed government of President Hamid Karzai. Timeline: Afghanistan attacks
The attacker was wearing a police uniform when he blew himself up at the entrance to the city's packed Eid Gah mosque, deputy provincial governor Abdul Satar Barez told AFP.
Victims lie on a street after a suicide bomb attack at a mosque in Maimana, capital of Faryab province, in this still image taken from video. Reuters
"Our latest death toll shows 41 deaths, and that might rise," he said.
"Nineteen were members of the security forces, including police, army and intelligence agents. Seventeen were civilians and five children are also among the dead."
Barez, like many other provincial officials, was at the scene at the time of the bombing and described the horror of the blast in the midst of a religious celebration.
"We had just finished Eid al-Adha prayers and we were congratulating and hugging each other," Barez said.
"Suddenly a big explosion took place and the area was full of dust and smoke and body parts of police and civilians were all over the place. It was a very powerful explosion."
One eyewitness, Sayed Moqeed, described the bomber as appearing to be in his early teens.
"Suddenly I heard a very big explosion," he said. "Everywhere were pieces of bodies, hands and limbs. The suicide attacker was in police uniform, he looked to be around 14 or 15 years old."
The four-day Eid al-Adha holiday is a celebration in which Muslims slaughter animals for feasts and distribute a portion of the meat among the poor, and the first day draws large crowds to mosques around the Islamic world.
Karzai strongly condemned the attack, calling the perpetrators "the enemies of Islam and humanity".
"Those who take the happiness of Muslims during Eid days cannot be called human and Muslim," he said.
Northern Afghanistan is relatively peaceful, with the Taliban, who were ousted from power in a US-led invasion in 2001, concentrating their operations in the south and east of the country.
But they have recently stepped up their activities in the north, despite the presence of more than 100,000 NATO troops in the country.
Last week, a huge roadside bomb ripped through a minibus carrying guests to a wedding party in the northern province of Balkh, near Faryab, killing 19 people and wounding 16 others.
An Afghan boy, who lost his father in a suicide attack, walks around a hospital in a daze in Maymana, Faryab province north west of Kabul, Afghanistan. AP photo
The United Nations says 1,145 civilians were killed in the war in the first six months of this year, blaming 80 percent of the deaths on insurgents.
Last year as a whole, a record 3,021 civilians died in the war, according to UN figures.
But Afghan police and government officials have increasingly become targets as local forces take on more responsibility for the fight against the insurgents as NATO prepares to pull out.
The foreign combat troops are due to withdraw by the end of 2014 and there are fears that the Taliban will extend their activities across wider swathes of the country against ill-prepared Afghan forces.