Pakistani Prime Minister Nawaz Sharif meets with President Barack Obama to discuss weapon use, among other issues. (Reuters)

President Obama spoke directly to the Taliban and its backers in Pakistan when he announced his plan last week to keep 5,500 U.S. troops in the country indefinitely.

“The only real way to achieve the full drawdown of U.S. and foreign troops from Afghanistan is through a lasting political settlement with the Afghan government,” Obama said.

The president had the opportunity to deliver that same message to Pakistani Prime Minister Nawaz Sharif — this time in person — when Sharif visited the White House on Thursday. For Obama, who had until recently promised to bring home American forces before the end of his presidency, the pledge to extend America’s longest war offers a new and potentially important point of leverage. The Taliban and its Pakistani patrons will no longer be able to wait out the U.S. presence.

“It’s a powerful statement and one Obama has never been able to make before because there had always been a fixed end date,” said former ambassador James F. Dobbins, who served as the administration’s special representative on Afghanistan and Pakistan.

The two leaders sidestepped areas of major disagreement between their countries in their public remarks from the Oval Office. “Both leaders expressed their commitment to advance an Afghan-owned and led peace and reconciliation process” and called on the Taliban to initiate “direct talks” with the Afghan government, according to a joint statement released by the Pakistanis after the meeting.

It’s unclear, though, whether Sharif has enough influence over Pakistan’s shadowy security services to nudge the Taliban to the negotiating table. “He has to make his own judgments about how far he can push his security establishment,” Dobbins said. “After all, he’s already been deposed once before.”

Sharif’s visit to the White House comes at a moment when the Taliban appears to be gaining ground in its long war with the U.S.-backed Afghan government. Late last month, the Taliban seized Kunduz, the first major city to fall to insurgents since 2001, and held out there for 15 days before Afghan forces were able to take it back. U.S. forces, supporting the Afghans in Kunduz, bombed a hospital run by the aid group Doctors Without Borders, killing 22 staff members and ­patients.

It’s unlikely that the Taliban’s handlers in Pakistan directed the attack on Kunduz. “But Kunduz is a symptom of Pakistan’s unwillingness or inability to deal with the Taliban problem,” said Vali Nasr, dean of Johns Hopkins School of Advanced International Studies.

Earlier this year, peace negotiations with the Taliban appeared to be gaining momentum. An initial round of talks in China in the spring were followed by a more substantive second round at Murree, a Pakistani resort town near Islamabad. The talks were backed by both Sharif and Afghan President Ashraf Ghani, who has risked significant political capital in pressing for negotiations with the Taliban and Pakistan. But the negotiations foundered when it was revealed that Mohammad Omar, the Taliban’s leader, had been dead for more than two years.

The Taliban’s recent battlefield victories likely have strengthened their negotiating position with the Afghan government. As a prelude to restarting negotiations, the White House would like Pakistan to step up operations against the Taliban and other insurgent groups that rely on havens in Pakistan.

“The best way to bring the Taliban to the table is to make it harder for them to enjoy that sanctuary in Pakistan,” Dobbins said.

The president’s meeting with Sharif wasn’t expected to produce any major breakthroughs with Pakistan. The relationship hit its nadir in 2011 after the unilateral U.S. raid to kill Osama bin Laden. The cross-border mission, launched from Afghanistan, embarrassed Pakistan’s military and was interpreted as an affront to its sovereignty.

Relations between the two countries have gradually improved since. “It’s a very complex relationship, and there are an enormous number of front-burner issues to discuss,” said Dan Feldman, who recently stepped down as the administration’s special representative for Afghanistan and Pakistan. “It’s a sign of the growing maturity of the relationship that all the key issues are on the table.”

The list of major issues include talks over limits on Pakistan’s nuclear weapons program, the potential sale of F-16 fighter jets and badly needed economic aid. The main focus of the relationship, though, continues to be security and counterterrorism operations.

“The relationship between Pakistan and the United States is security-centric, and there is no emphasis on building and strengthening Pakistani civilian institutions,” said Farhatullah Babar, a senator from Pakistan’s People’s Party. “The fact is, when there is more emphasis on security ties, it undermines the civilian institutions.”

The Pakistanis have mounted major operations in the restive North Waziristan region in recent months and have taken some heavy casualties. U.S. officials, though, would like Pakistan to do more to root out the Haqqani network, a Pakistan-based group affiliated with the Taliban that is responsible for some of the bloodiest attacks of the Afghan war.

The Pentagon could withhold hundreds of millions of dollars from Pakistan’s military over concerns that it is not doing enough to combat the Haqqani network. Since 2002, the Pentagon has reimbursed Pakistan about $13 billion for its support of the U.S.-led war in Afghanistan. But Congress made part of this year’s $1.1 billion payment contingent on Pakistan’s willingness to crack down on the Haqqani network.

Sharif outlined for Obama the operations that Pakistan is taking to degrade the network. Islamabad’s efforts in the past have been criticized by the Pentagon as insufficient.

In addition to a resurgent Taliban, al-Qaeda appears to be moving from its sanctuaries in Pakistan and into Afghanistan. Earlier this month, U.S. forces began a major operation against al-Qaeda in Kandahar province, launching 63 airstrikes on militant training bases.

“The whole thing is quite extraordinary to me,” said Bruce Riedel, a former CIA official who helped lead Obama’s initial 2009 review of Afghanistan and Pakistan policy. “For seven years, the U.S. military and the White House rarely talked about al-Qaeda in Afghanistan. There’s a serious problem with al-Qaeda regeneration. Now we can no longer publicly ignore it.”

Tim Craig contributed to this report.