A Yemeni security official said the gunman walked into the mosque during the weekly sermon and opened fire with his assault rifle. He was soon taken into custody, said the official, who requested anonymity because he was not authorized to speak to the press.
The official described the gunman as "deranged." But tribal leaders, who asked not to be identified because they feared government reprisal, dismissed the claim of mental illness saying the man was a 32-year-old driver for a legislator in the area.
The official said the gunman also wounded 26 people, 10 of them critically.
Analysts said the recent targeting of mosques - once rare - represented a dangerous escalation in the northern conflict.
The attack took place in the town of Kohal, in Amran, a predominantly Shiite province just north of the capital San'a. Yemen is a predominantly Sunni Muslim.
On May 2, a booby trapped motorcycle exploded outside a Shiite mosque in the northern town of Saadah, near the Saudi border, killing 18 worshippers as they were leaving.
That area in northern Yemen is the site of a rebellion by Shiite Muslims of the al-Zaydi sect that erupted in 2004 and has since killed thousands. It is not immediately clear if the Amran attack, which happened 150 kilometers to the south, was connected.
The government blamed that mosque bombing on rebel leader Abdel-Malek al-Hawthi who is leading the rebellion. But 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.
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 Qaeda is believed to be behind attack.
Yemen is the ancestral homeland of al Qaeda 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 USS Cole destroyer in the Yemeni port of Aden that killed 17 American sailors and an attack on