As he bumped through the night, driving between rallies held in courtyards and in small village squares, Mr. 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.

Mr. Khan, a burly man with an irreverent sense of humor, did not mention the Taliban in his campaign speeches. The talk was of bread-and-butter issues, not bullets: access to drinking water, electricity and gas. “I don’t want to depress people,” he said, citing increased sales of anti-anxiety medication in local pharmacies.

But such candidates are silent on delicate issues for another reason, too: they fear antagonizing local militants.

Nowshera shares a border with Darra Adam Khel, a tribal district famed for its gunsmiths, where militants have engaged in firefights with the security forces. Just a few miles away lies the infamous Akora Khattack madrasa, where several generations of Taliban leaders have received their education.

The problem is exacerbated by arguments among Pakistan’s politicians about how to handle the Taliban. Mr. 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 American policies, particularly drone strikes, his party is expected to do well in Khyber-Pakhtunkhwa.

But critics accuse Mr. Khan of being soft on the Taliban because he advocates talks with the militants, not fighting. In a television interview on April 15, Mr. Khan said that the Taliban were bombing his opponents “because they supported America’s war.”

Similarly, Nawaz Sharif, the opposition leader who is a favorite to become the next prime minister, has also been measured in his criticism of militancy.