NOWSHERA, Pakistan — When Shahid Khan started talking, his gunmen clambered onto a school’s rooftop, scanning the surrounding hills with flashlights, anticipating a possible attack.
Below them, Khan, a candidate for his region’s provincial assembly, addressed potential voters — poor farmers and village traders, gathered on a cluster of rope beds outside the school, listening raptly to his promises. Then, after wolfing down snacks offered by his hosts, he abruptly left.
‘‘They say it’s not safe around here,’’ said Khan, as he leapt into a waiting car, trailed by a bodyguard. ‘‘We’d better get going.’’
Electioneering has taken a dark twist in northwest Pakistan, where a concerted campaign of Taliban attacks against the main secular party is violently reshaping the democratic landscape ahead of parliamentary elections scheduled for May 11.
In the past 10 days, militants have carried out four bombings and one grenade attack against Khan’s Awami National Party, which has governed Khyber-Pakhtunkhwa Province since 2008, and whose secular ideology is repugnant to the Taliban’s vision of imposing an Islamic caliphate in Pakistan.
In the worst attack, last Tuesday, a suicide bomber killed 19 people and wounded dozens in central Peshawar, narrowly missing the former railways minister, Ghulam Ahmed Bilour.
The Taliban have warned voters to stay away from rallies organized by the three main secular parties — the Awami party, President Asif Ali Zardari’s Pakistan People’s Party, and the Karachi-based Muttahida Qaumi Movement.
But so far, they have concentrated their fire on the Awami party, restricting its candidates’ ability to campaign freely, and tilting the field in favor of more conservative parties, analysts say.
‘‘The most effective campaign is being run by the Taliban,’’ said Asad Munir, a retired army brigadier with the army’s Directorate for Inter-Services Intelligence, who comes from the northwest. ‘‘They are holding the state of Pakistan hostage, and doing their activities as they want.’’
This election was never going to be easy for the Awami party, which has already attracted sharp criticism for poor governing skills and corruption while in office — deficiencies that analysts, and some party insiders, say will hurt it during the balloting.
But now the Taliban seem determined to wipe out the party as a political contender.
In the past five years, militants have killed 700 Awami officials and supporters, including two lawmakers and a senior minister, officials say — more casualties than any other party in Pakistan.
In the southern city of Karachi, where the party enjoys support in ethnic Pashtun neighborhoods, about 40 activists have been killed in the past six months, effectively shutting down the party’s activities there.
In Nowshera, a small town 25 miles east of Peshawar, Shahid Khan holds small rallies, often at night and with little notice. He quietly sends advance teams of supporters to check out potential sites. And he is always accompanied by a contingent of private guards and regular police officers, all heavily armed.
“Every time my team leaves my house, we are not just praying for election success — we are praying for our lives,’’ he said as he drove down a cobblestone lane that snaked between high-walled houses.
Once peaceful, the Nowshera district, which has a substantial military presence, has been increasingly affected by Taliban violence, suffering 26 attacks in 2012 and five so far this year, according to the police. Last month, a car bomb explosion at a refugee camp killed 16 people and wounded 31. In February, militants assaulted a police checkpost, then threw grenades at a police vehicle on a major highway, killing one officer. In some towns, Taliban fighters have forced shops selling movies to close.
As he bumped through the night, driving between rallies held in courtyards and in small village squares, Shahid Khan pointed to a school that was bombed by the Taliban last year. He helped pay to have it rebuilt. ‘‘These days, you never know what can happen,’’ he said.
The problem is exacerbated by arguments among Pakistan’s politicians about how to handle the Taliban. Shahid Khan’s main rival is a candidate of Pakistan Tehreek-e-Insaf, the party of Imran Khan, the former cricket star. With his glamorous youth appeal and vocal opposition to US policies, particularly drone strikes, Imran Khan’s party is expected to do well in Khyber-Pakhtunkhwa.
But critics accuse Imran Khan of being soft on the Taliban because he advocates talks with the militants, not fighting. In a television interview on April 15, Imran Khan said the Taliban were bombing his opponents ‘‘because they supported America’s war.’’