Police say a suicide bomber has killed at least eight people in northwestern Pakistan, including a provincial government minister, as the country marked the Muslim festival of Eid al-Adha.

Israullah Gandapur, the minister of law for Khyber Pakhtunkhwa province, was killed on Wednesday in his home near the city of Dera Ismail Khan as he greeted residents of his home village who had come to celebrate the first day of Eid.

More than 30 people were wounded in the attack, including the minister's elder brother, said Irfan Mahsud, the assistant commissioner, Dera Ismail Khan, located nearly 300km southwest of the capital, Islamabad.

"I saw so many dead people and injured people crying for help," said eyewitness Haseeb Khan, whose new white holiday clothes were drenched in blood. "There were arms, legs and heads everywhere."

The attacker first killed the guard at the house and then blew himself up inside the guest room of the minister's residence, another police official said.

The minister was rushed to the hospital in critical condition but died along the way.

The suicide bomber had managed to break into the area despite "very tight security", the Provincial Health Minister Shaukat Yousafzai told AFP news agency.

Wednesday's attack involved 8-10 kilograms of locally made explosive, Inayat Ullah, a bomb disposal expert, told AFP.

Group claims responsibility

Ansar al Mujahideen, a group allied to but not part of the Pakistani Taliban, claimed responsibility for the attack.

The group's spokesman, Abu Baseer, said it was in retaliation for the deaths of men killed during a July jailbreak in the same city.

He was referring to a major operation by fighters from the al-Qaeda-linked Pakistani Taliban who disguised themselves as police and broke 250 prisoners out of a jail.

The province is ruled by Pakistan Tehreek-e-Insaf (PTI), a party led by former cricketer Imran Khan, which favours peace talks with the Taliban.

Gandapur is now the third lawmaker from the province to have been killed following the general elections on May 11.

Farid Khan and Imran Khan Mohmand, killed in separate attacks in June, were also members of the PTI party.

The main Pakistani political parties including PTI last month backed a government proposal to formally seek negotiations with the militants, who have been waging a war against the state since 2007.

The Taliban have said they are open to talks, but they also say they will not disarm, do not recognise the Pakistani constitution, and will not talk to the government until the army pulls back from their strongholds and all their prisoners are released.