SAN'A, Yemen — A Yemeni security official says a gunman opened fire in a mosque in a predominantly Shiite northern town, killing at least eight worshippers and wounding dozens.

Police have detained the attacker, who witnesses said opened fire with an assault rifle during the weekly sermon.

The official spoke on condition of anonymity because he was not authorized to speak to the press.

The attack took place in the town of Kohal, in Amran, a predominantly Shiite province north of the capital San'a.

On May 2, a booby-trapped motorcycle exploded outside a Shiite mosque as worshippers were leaving, killing 18.

The area is the site of a rebellion by Shiite Muslims of the al-Zaydi sect that erupted in 2004 and has killed thousands. It is not immediately clear if the Amran attack, which happened about 100 miles to the south, was connected to that insurgency.

The government of predominantly Sunni Yemen blamed the mosque bombing on rebel leader Abdel-Malek al-Hawthi, who is leading the rebellion. Al-Hawthi denied involvement.

The Shiite rebels accuse the government of corruption and of being too closely allied with the West. The government accuses al-Hawthi of sedition, forming an illegal armed group and inciting anti-American sentiment.

Attacks on mosques were once rare in Yemen and analysts have said the targeting of a mosque is a dangerous escalation in the northern conflict.

In a separate incident, a police official said that two Katyusha rockets were fired at an oil refinery in the Yemeni port of Aden but there was no word of causalities.

The official said that al-Qaida is believed to be behind attack.

Yemen is the ancestral homeland of al-Qaida leader Osama bin Laden. The group has active presence in Yemen despite government efforts to destroy it.

The group was blamed for the 2000 bombing of the destroyer USS Cole in the Yemeni port of Aden, which killed 17 American sailors, and an attack on a French oil tanker that killed one person two years later.