When the United States signed off on letting the Taliban dispatch a delegation to Qatar in 2011, Washington had high hopes that the tiny Persian Gulf emirate would serve as a safe place to hold peace talks that could bring to an end a decade of war.

The Taliban appears to have had broader ambitions: to use its foothold in Doha as a de facto diplomatic post for positioning itself as an ascendant political force in Afghanistan as the United States disengages in the year ahead. The most striking signal was a recent trip that Doha-based Taliban members took to Tehran, which the insurgent group billed as a foreign relations coup.

This week offered more evidence that the militant group and its would-be Afghan and American interlocutors have sharply different visions for the Qatar office, which formally opened Tuesday. The ribbon-cutting turned into a debacle for the United States, which scrambled to defuse the Afghan government’s outrage over the Taliban’s display of its flag and a banner reading the “Islamic Emirate of Afghanistan,” the country’s name during the Taliban rule of the 1990s.

The diplomatic row between Washington and Kabul froze negotiations on a security agreement that could allow U.S. troops to stay here past 2014. Meetings between U.S. and Taliban officials that were scheduled for Thursday were postponed, setting an awkward tone for Secretary of State John F. Kerry’s visit to Qatar this week to discuss the Syrian conflict. And questions lingered about what the group hopes to accomplish in Doha.

An end to discretion

Until this week, Taliban envoys in Doha led a shadowy existence, living mostly in luxury hotels under close surveillance of the Qatari government. They held secret meetings with diplomats from Germany, Norway and Japan, among other countries.

Their discretion came to an end this month, however, with a Taliban announcement that its emissaries traveled from Doha to Tehran at the invitation of the Iranian government.

The trip was not the first contact between Shiite-led Tehran and the Sunni Taliban, which have a long history of mistrust and animosity, partly because of clashing religious ideologies. But it marked the most high-profile meeting between two stakeholders in the Afghanistan conflict that analysts say might overlook sectarian differences in pursuit of common goals: undermining the United States, a shared nemesis, and getting the American military to leave the region for good once NATO’s mandate in Afghanistan expires at the end of next year.

“You could look at this trip as the beginning of serious regional diplomacy that is going completely around us,” said Vali Nasr, a former State Department official involved in Afghanistan policy who is dean of the Johns Hopkins School of Advanced International Studies. “We think we’re going to shape the post-2014 era with military support, but there are other games happening here, and the Taliban are positioning themselves.”

Iran’s ambition for a greater role in Afghanistan unsettles the United States, which came to see Tehran as a major spoiler in the Iraq war. U.S. officials accused Iran of fueling violence in Iraq by deploying militias to fight American troops and have accused Tehran of aiding the Taliban militarily in a more limited way.

The Taliban, whose top leaders are thought to be based in Pakistan, has long aspired to return to power and has attempted to maintain the semblance of a sovereign state in provinces where it holds sway.

“Taliban have not visited Iran as an insignificant party or group,” the group said in a statement posted on its Web site, in which it hailed the meeting as groundbreaking. “Rather, they have been invited by the Iranian side as an independent political system and crucial issues have been brought under discussion.”

In another statement, the group said it is “pursuing diplomatic relations” with “different countries of the region and the world on the basis of reciprocal reverence, equality and non-interference in others’ internal affairs.”

With the U.S. drawdown accelerating and Afghan President Hamid Karzai’s time in office likely to end next spring, analysts say the Taliban has little incentive to pursue a grand bargain that could lead to a cease-fire. As a precondition for an end to hostilities, the United States wants the Taliban to publicly renounce ties to al-Qaeda and recognize the Afghan constitution. The two parties, however, are also interested in a narrower deal: the exchange of a kidnapped U.S. soldier for five Taliban leaders imprisoned at Guantanamo Bay, Cuba.

Even after the Qatar office opened, the Taliban has continued fighting the NATO troops it calls “foreign invaders” and their Afghan allies, which the group disparages as “puppets.” On Wednesday, it asserted responsibility for a rocket attack that killed four U.S. troops in eastern Afghanistan.

The Tehran relationship

The U.S. Embassy did not respond to a request for comment about the Tehran visit. But American officials say they continue to hold out hope for a negotiated end to the Afghanistan conflict.

“If peace and stability is to be brought to Afghanistan, I think some form of political reconciliation is critical,” Gen. Joseph F. Dunford Jr., the commander of international troops in Afghanistan, told the BBC in a recent interview.

The Tehran visit appeared to have taken the Afghan government by surprise. After it was reported June 1 by the semiofficial Iranian Fars News Agency, Karzai’s government summoned Iran’s ambassador.

The Iranian Foreign Ministry told the Kabul government that no such meeting took place, the Afghan Foreign Ministry later said, but Afghan officials and lawmakers cast doubt on the denial.

Some Afghan lawmakers criticized the visit, saying the Taliban was abusing its foothold in Qatar, an oil-rich emirate that has played an outsize role in regional politics.

“We at the parliament have raised our concerns about the Taliban office in Qatar,” said Zahir Sadat, a lawmaker from northeastern Panjshir province. “The Taliban can begin their official political activity from there and use it to earn legitimacy for what they are doing.”

Iran invited a delegation from the Taliban to Tehran in fall 2011 for a conference of Islamic scholars. Tehran has since remained in contact with the Taliban, according to Afghan lawmakers and political analysts who study the group, a notable shift considering that Iran and Taliban-ruled Afghanistan nearly went to war in the 1990s.

Iran is probably also seeking to influence Afghan policy on other issues, including Kabul’s counter-narcotics strategy. Tehran is concerned about the growing number of opium addicts in Iran, a phenomenon that has coincided with a poppy boom in Afghanistan.

Iran has sought favor with the Karzai government in recent years, but it might be recalibrating its engagement with political actors in Afghanistan, said Abdul Satar Saadat, an Afghan lawyer and political analyst.

“With 2014 approaching, the Taliban will announce they have the upper hand and it was due to their fighting and campaign that the foreigners left,” he said. “It gives them credibility on the political side.”

Sayed Salahuddin contributed to this report.