A suspected Sunni extremist opened fire in a Shiite mosque Thursday and then blew himself up, killing nine people on the eve of a religious festival that has been scarred by sectarian violence in the past.

The blast in northwestern Pakistan wounded at least 20 people including a prominent Shiite cleric, adding to tensions in the country as it prepares for parliamentary elections Feb. 18 that many predict will weaken President Pervez Musharraf's grip on power.

Suspected Islamic militants have launched a wave of homicide attacks against security forces and politicians in recent months, killing at least 400 people including opposition leader Benazir Bhutto, a secular politician who had vowed to battle the militants.

Arshad Ali, whose brother died in Thursday's blast, said the attacker was a man about 18 years old who walked into the crowded Imambargah Qasim Baig mosque, opened fire with a pistol and then blew himself up.

"People present there tried to stop him," Ali said, wailing and beating his chest in grief. "He took out a pistol, shot three times and then blew himself up."

It was not immediately clear whether any of the dead or wounded were hit by the gunfire.

Peshawar police chief Tanvir Sipra said nine people were killed, including a policeman who tried to stop the bomber from entering the mosque. A few policewomen were wounded, he said.

Prominent Shiite cleric Syed Rza Shah, who was wounded in the attack, had traveled to Peshawar from Rawalpindi to address a gathering at the mosque, said Mohammed Iqbal, another police official. Shah's deputy, Kalb-e-Abbas, was among the dead.

A crowd of enraged Shiites, crying and beating their chests, prevented an Associated Press reporter from entering. Police also had difficulty approaching the mosque. Hundreds more Shiites gathered at the hospital where the wounded were taken and chanted religious slogans.

Ashoura, which falls this weekend, is the culmination of Shiite rites during the holy month of Muharram when they mourn the seventh century death of the Prophet Muhammad's grandson, Imam Hussein — an event that led to the split in Islam between the Shiite and Sunni sects.

Shiites stage processions and beat their bare backs with chains and blades, bloodying themselves in a sign of penitence. While most Shiites and Sunnis live peacefully together in this overwhelmingly Islamic nation of 160 million people, extremist groups from both sides are blamed for attacks.

Such violence breaks out during Muharram each year. In 2005, about 50 people were killed when a bomb ripped through a Shiite shrine in southwestern Pakistan.

Sunnis outnumber Shiites by about four to one in Pakistan.

In a prerecorded appearance broadcast late Thursday on state television, President Pervez Musharraf described homicide attackers as "mad" and misguided into thinking they were serving Islam.

Also Thursday, near Pakistan's border with Afghanistan, Taliban fighters seized their second fort in as many days after dozens of troops abandoned the outpost without firing a shot, the insurgents and an intelligence official said.

An army spokesman denied the fort had fallen, and was it not immediately possible to reconcile the conflicting claims. Another takeover would highlight the rising militant control of the lawless area, where top al-Qaida leaders are thought to be hiding.

The intelligence official, who requested anonymity because he was not authorized to speak to the media, said the paramilitary troops fled the roadside post without a fight after the militants warned them to vacate or face attack.

The official, who was in the area, said the troops went to a military base in the nearby town of Jandola.

Maulvi Mohammed Umar, a purported militant spokesman, said the troops surrendered after 500 fighters surrounded the post.

"We released them (the troops) under the spirit of Islam," he said by telephone from an undisclosed location. "The Taliban have now hoisted their white flag on the fort."

But the army denied the fort had fallen.

"I strongly contradict this news and this post in our control," said army spokesman Maj. Gen. Athar Abbas.

Pakistan and its military has received billions of dollars in U.S. aid since Musharraf allied the country with Washington after the Sept. 11 terror attacks.

On Wednesday, militants overran the Sararogha Fort in a battle that left seven soldiers dead and at least 15 troops missing.