Altaf Khan, spokesman for Pakistan’s permanent election commission, said the commission simply followed court orders. But activists and politicians say the courts are influenced by the military, which has undertaken numerous coups in the country’s modern history.

The military has denied it influences the courts.

“The international community will have to respect the sovereignty and laws of my country,” Mr. Khan said in an interview. If anyone has a complaint against a candidate supported by evidence, he said, “they should let us know.”

Omar Shahid Hamid, the senior police superintendent for Karachi’s southern district, used to conduct regular check-ins with Mr. Farooqi as a member of the police counterterrorism unit. He said he was surprised that Mr. Farooqi’s nomination papers were not rejected, but not that he was running.

“Farooqi has always had an interest in electoral politics and a desire to get mainstreamed, to be accepted as a political force and get rid of his baggage as a militant,” Mr. Hamid said. “They see this as the future, the only way forward with the establishment.”

In Pakistan, “the establishment” is code for the military, which is accused by both Pakistan’s former government and the international community of supporting extremist groups to achieve its defense and foreign policy objectives.

The military in recent years has discussed plans to “mainstream” extremists, allowing them to shed their violent pasts and become politicians, according to cabinet members of the previous government who were involved in those discussions. It is a plan opposed by the incumbent government and activists across the country.

Noticeably absent from the list of eligible election candidates are several from the Pakistan Muslim League-Nawaz. The PML-N formed the previous government and saw its prime minister, Nawaz Sharif, ousted by the Supreme Court last July for failing to disclose assets abroad in his 2013 election application.