The early Norwegian contacts were maintained around the personal relationships of Mr. Ramslien, an unconventional diplomat who had been a Christian missionary in Pakistan in the 1960s. He understood that the Taliban’s worldview was rooted in religion, and could communicate with them — and even interpret for them — in Urdu, which he speaks fluently.

During his years as a diplomat in Islamabad, stretching back to the 1990s, Mr. Ramslien had made an impression not only on the Taliban government in Afghanistan, but also on the Pakistani madrasas — the religious schools that gave birth to the Taliban movement and to this day fill its ranks with foot soldiers.

Many of those seminaries were a legacy of American funding of the Islamic insurgency against the Soviet Union in Afghanistan. After the Soviet withdrawal, and after the United States virtually abandoned the region in the 1990s, Mr. Ramslien made a priority of continuing engagement with Pakistani and Afghan religious leaders — which he felt was necessary because in isolation those figures could become more dangerous.

With those credentials, it was Mr. Ramslien the Taliban approached in 2007 when they were looking for a go-between.

The initial contacts with the Taliban came with enormous risks for both sides. Norway was “dealing with an illegal armed group that was not only listed by the United Nations as a terrorist group, but was also in direct conflict with a NATO force that included Norwegian troops,” according to a recent report by a high-ranking commission on Norway’s 15-year involvement in Afghanistan.

The Taliban risked arrest by breaking United Nations travel restrictions, while holding meetings inside Pakistan would bring further scrutiny from a potential spoiler: the country’s powerful military Inter-Services Intelligence service — the ISI — which was protecting the Taliban in their Pakistani havens. Al Qaeda, too, wasn’t happy about the Taliban projecting an image of independence.

“They knew they had to make the ISI happy,” Mr. Ramslien said of the Taliban. “Then, at the same time, play another game totally independently.”