Zahir ul-Islam
© ReutersLt. Gen. Zahir ul-Islam
Islamabad - The prime minister of Pakistan appointed a new general to run the country's most powerful intelligence agency on Friday, signaling an important change in the military leadership at a pivotal moment in relations with the United States.

Lt. Gen. Zahir ul-Islam will take over as the director general of the Inter-Services Intelligence Directorate, or ISI, on March 18, replacing Lt. Gen. Ahmed Shuja Pasha, who has held the post since 2008, a spokesman for Prime Minister Yousaf Raza Gilani said.

The ISI chief is the second most powerful figure in the military - some would argue in the country - and General Islam is likely to play a significant role in peace talks with the Afghan Taliban, a movement the ISI has long been accused of supporting.

Although the ISI officially reports to the prime minister, in reality it is controlled by the army chief, Gen. Ashfaq Parvez Kayani, with whom General Pasha had a close relationship during the agency's turbulent relationship with the United States in recent years.

A succession of spy scandals sent the ISI's relationship with the Central Intelligence Agency - and, more broadly, with the United States - to a historic low in 2011. Tensions rose in January 2011 after a C.I.A. contractor shot and killed two Pakistanis in Lahore, and then worsened in May after the surprise American raid that killed Osama bin Laden in the Pakistani town of Abbottabad, 35 miles north of the ISI's headquarters in Islamabad. In September, Adm. Mike Mullen, then chairman of the Joint Chiefs of Staff, said at a Congressional hearing that the pro-Taliban militant group known as the Haqqani network was a "virtual arm" of the ISI, prompting fresh tumult.

However, the ISI and the C.I.A. have quietly worked to rebuild ties in the past month, and officials from both countries say the relationship is slowly mending.

General Islam commands the army corps in Karachi, considered a plum posting and a sign of his good standing with General Kayani. From 2008 to 2010 he served as director of the ISI section responsible for internal security.

"He's a safe choice," said Wajahat S. Khan, a journalist who has written about internal military politics. "He's served in the ISI, he's from an infantry wing, and he's pretty media savvy - which is what they need right now."

General Islam's first job is likely to involve refashioning relations with Washington, which have been virtually frozen since an erroneous American attack near the border with Afghanistan in November killed 24 Pakistani troops. At a special joint session of Parliament set for this month, Pakistan's politicians will debate the broad contours of a new policy toward the United States.

Few doubt, however, that core elements of the relationship will be determined by General Kayani and General Islam, in consultation with President Asif Ali Zardari.

One likely obstacle will be the continuing C.I.A. drone strikes in the northwestern tribal belt, which are wildly unpopular. In the latest strike, 12 people were killed in South Waziristan on Friday morning, Pakistani intelligence officials told The Associated Press.

The ISI has a fearsome reputation after decades of political manipulation and meddling in militancy. But in recent years, it has faced stark challenges. Pakistani Taliban militants have killed dozens of ISI employees since 2007, undermining the army's authority.

The ISI is also facing challenges on the judicial front. This week the Supreme Court resumed hearings into an election-rigging scheme in which the ISI distributed $15.5 million to favored politicians in an ultimately successful bid to influence the 1990 election.

On Friday, the court heard testimony from a former ISI chief, Asad Durrani, who admitted to running the scheme but denied that it was part of ISI policy.

The hearing also included an extraordinary moment involving Gen. Mirza Aslam Beg, a former army chief who is said to have blessed the illegal scheme.

Infuriated by what was deemed to be an insubordinate affidavit that the general filed to the court, Chief Justice Iftikhar Muhammad Chaudhry demanded that the general apologize. "Is he here to play golf?" the justice asked.

Another judge said, "We will not allow anyone to play with our dignity."

General Beg wrote an apology on a piece of paper, and the case was adjourned until March 15.