A shootout at a wedding party in northern Afghanistan has killed at least 21 people and injured eight more, an official said on Monday.

Abdul Jabar Perdili, police chief of Baghlan province, said a gunfight broke out between two groups attending the wedding in Dih Salah district late on Sunday evening. He said that most of the dead were wedding guests and at least two of the wounded were younger than 18 years old.

The gunmen involved were guests at the party and thought to be members of illegal local militias, rather than groups such as the Taliban or al Qaeda, the provincial chief said.

The shooting broke out as music started for the nearly 500 guests and the men were reportedly sent to the event by a local commander who found out that one of his rivals was attending the wedding, a senator from the province, Samay Faisal said.

"They opened fire at the crowd, which resulted in the killing of 22 people and the wounding of 10 others," stated Faisal. Other guests at the wedding were also armed and shot back at the attackers.

Baghlan and other provinces of the north have been plagued by insurgent attacks since the U.S.-led invasion in 2001 that toppled the Taliban. However, the war is often used as a cover for criminal activity and personal feuds.

The police chief of Dih Salah, Col. Gulistan Qasani, said hostility between the two groups involved in the gunfight had been simmering for many years. "The clash broke out after a relative of a provincial police official was assassinated during the wedding party," Qasani said.

"When we collected the bodies it was difficult to determine who were the shooters and who were not, because I could not find any weapons," Qasani added.

The Associated Press contributed to this report.