Pakistani Prime Minister Nawaz Sharif looks out the window of his plane after attending a ceremony to inaugurate the M9 motorway between Karachi and Hyderabad, Pakistan, on Feb. 3. (Caren Firouz/Reuters)

To U.S. and international officials, Hafiz Mohammad Saeed is a terrorist who orchestrated a bloody urban siege that killed 166 people in India in 2008. But to his many devout followers in Pakistan, he is a champion of Islamic values and Kashmiri independence from India.

To U.S. and international officials, Shakil Afridi is a courageous man who helped the United States track down and kill Osama bin Laden in 2011. But to many Pakistanis, he is a traitor who sold his services to a Western adversary of Islam and should remain in prison.

Therein lies the conundrum facing Pakistani officials today as they scramble to forestall punitive actions by the Trump administration — and ease pressure from other foreign partners, including China — without provoking turmoil at home, especially among Muslim militants the state has long coddled as proxies against India.

Suddenly confronted with a U.S. president who has declared war against Islamist extremism and has expressed little interest in the long history of political accommodation and security alliances between Washington and Islamabad, officials here are struggling to find a middle ground that may no longer exist.

The disarray was evident in clashing public statements by two government officials concerning the draconian travel ban imposed by Trump last week on all visitors from seven Muslim-majority countries.

White House aides suggested last week that ban might be expanded to include Pakistan and other countries with terrorist links. On Saturday, Pakistani media outlets quoted a White House spokesman telling the BBC that there are “no immediate plans” to add Pakistan, Afghanistan or Lebanon, but warning that this could change if the countries stop complying with U.S. requests for information.

Foreign Ministry spokesman Nafees Zakaria, addressing a news conference Thursday, noted deferentially that “it is every country’s sovereign right to decide its immigration policy.” He said Pakistan looks forward to continuing its “long-standing and cooperative relations” with Washington.

But Interior Minister Chaudhry Nisar, speaking at a seminar, declared bluntly that “no solution from America and the West can be imposed on our region” and that the West should stop “blaming Islam” for the world’s ills. “The tendency to label every man with a beard and every woman wearing hijab as a potential terrorist should cease now,” he added.

In the past week, Pakistan has taken steps to tighten legal nooses around both Saeed and Afridi, confining the firebrand cleric to house arrest and denying travel documents to the imprisoned doctor’s family. Taken together, these moves send a double message: The government is serious about reining in a high-profile Islamist militant with a U.S. bounty for his arrest, but it is also serious about keeping an alleged traitor — whom Trump once vowed to set free — behind bars and under wraps.

The crackdown on Saeed and his group, which has been allowed to function freely for the most part, is seen by many here as a hasty conciliatory gesture to the new administration in Washington. But Pakistani officials insist it was the product of long internal deliberation — and further proof of a permanent shift from official tolerance for extremists who once served as Pakistan’s deniable agents in India and Afghanistan.

“Pakistan is not merely an aspirant for cooperation with Washington, it is a serious and credible partner,” Tariq Fatemi, a senior aide to Prime Minister Nawaz Sharif, said in an interview Friday. He said Sharif’s government, with strong support from the army, is determined to clear the country of all militants. “We will kill them or drive them out,” he said. “Any willingness to look the other way is no longer there.”

Some analysts said that while Pakistan is concerned about the Trump administration expanding its travel ban or cutting off aid, it also faces other sources of pressure to clamp down on extremists. One is China, Pakistan’s giant neighbor and major economic partner, which does not want its investments — especially the planned $46 billion China-Pakistan Economic Corridor, or CPEC — threatened by violence.

The other is an intergovernmental watchdog agency, the Financial Action Task Force, which monitors money laundering and terrorist financing. The group, which can blacklist countries that don’t have enough safeguards in place, has reportedly raised new alarms about “gray payments,” or money being funneled as charitable donations to or from militant groups in Pakistan, including Saeed’s.

“There is a lot of speculation about what Trump might do, but I think we are seeing a confluence of other factors,” said Amir Rana, director of the Pakistan Institute for Peace Studies. “The financial issues are the most urgent. The CPEC has injected a lot of hope and optimism into the country, and everyone wants to make sure it succeeds.”

Some commentators say that to prove it is serious about curbing Islamist extremism, the government must stop sending mixed signals to groups like Saeed’s as well as to hard-line sectarian movements, which are often banned but then allowed to regroup under new names. Saeed once headed a militant group, Lashkar-e-Taiba, that was accused by India of staging the Mumbai siege. Now he heads two other groups that claim to be charitable and educational, but are also fiercely anti-India.

Fatemi said that the government also intends to counter extremist ideas with persuasion, registering radical seminaries and “bringing them into the mainstream” through a National Action Plan established by Sharif. “We are going to bring about a major shift in the thinking process of people on the fringes,” he said.

But that message is not so easy to spread in an impoverished country of 180 million people, about 80 percent of them Muslims. Today, more than 2 million youths are studying in seminaries, and groups like Saeed’s enjoy wide popularity. The cause of Kashmiri oppression has been a national rallying cry for decades, and many Pakistanis have been taught to believe that India, Israel and the United States are mortal enemies of Islam.

Among the few Pakistanis who express hope for sympathy from the Trump administration are the relatives of Afridi, who has been in prison for six years on charges of abetting Islamist militants. His family says it believes the real reason was his role in locating bin Laden, by conducting a medical survey in the city where the al-Qaeda leader was found and killed by U.S. Navy Seals.

This week, relatives and attorneys for Afridi said the government had refused to renew identity documents for his family members and had placed their names on a list of Pakistanis who are banned from leaving the country. In an interview, his younger brother, Jamil Afridi, 55, said he hoped the Trump administration would come to the doctor’s aid.

“My brother did nothing wrong. He was a true American hero who helped the United States eliminate the world’s most wanted terrorist,” Afridi said. “I congratulate President Trump and I am optimistic about him, because he said he would help free my brother once he was elected to office. He is a man of action who does what he says.”

Haq Nawaz Khan in Peshawar contributed to this report.

Read more:

Pakistani cleric arrested to appease Trump administration, India, supporters say

In Pakistan, five girls were killed for having fun. Then the story took an even darker twist.

Pakistan plans to expel Turkish teachers linked to opposition at home

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news