After the explosion, a mob burned several shops and vehicles near the blast site in Dera Ismail Khan, police officer Saadullah Marwat said.
Nuclear-armed Pakistan is undergoing a wave of Islamist violence that risks destabilizing the country as the West seeks its support in fighting al Qaeda and Taliban in neighboring Afghanistan.
The motives for the shooting and blast were unclear, but in the past members of Pakistan's majority Sunni Muslim community have attacked Shiites, considered by some to be heretical.
Northwestern Pakistan is home to scores of al Qaeda and Taliban extremists. They are Sunni, but mostly attack Pakistani police and military trying to root them out of the area.
The victims were attending the funeral of cleric Allama Nazir Shah Naqvi, who was fatally shot earlier Friday, Marwat said, adding it was not yet clear if the blast was from a hidden explosive device, a grenade or a suicide bomber.
Eight bodies were taken to a local hospital where 28 people wounded in the attack were being treated, including some in critical condition, Dr. Farid Mehsud said.
Also in the border region, a suicide bomber late Thursday attacked a mosque where government-backed anti-militant tribesman were praying, killing eight, including the head of the group, officials said.
Seeking to curb soaring violence in Afghanistan, America is believed to have staged some 20 missile strikes on militant targets in Pakistan since August, almost all of them aimed at the lawless tribal region along the Afghan border.
But for the first time Wednesday, the missiles targeted militants beyond the tribal areas, deeper inside Pakistan. Six suspected insurgents were killed.
Pakistan's Foreign Ministry summoned U.S. Ambassador Anne Patterson on Thursday to protest the strike, the second time she has been called in since August.
"It was underscored to the U.S. ambassador that such attacks were a violation of Pakistan's sovereignty," a ministry statement said. The foreign secretary stressed the attacks must be stopped.
The U.S. rarely confirms or denies involvement in strikes inside Pakistan, which are believed to be carried out mainly by unmanned CIA drones flown from Afghanistan.