WASHINGTON (Reuters) - The breakthrough leading to Saturday’s surprise exchange of a U.S. prisoner of war for five Guantanamo detainees suddenly became possible after harder-line factions of the Afghan Taliban apparently shifted course and agreed to back it, according to U.S. officials.

U.S. President Barack Obama watches as Jami Bergdahl (L) and Bob Bergdahl (C) talk about the release of their son, prisoner of war U.S. Army Sergeant Bowe Bergdahl, during a statement in the Rose Garden at the White House in Washington May 31, 2014. REUTERS/Jonathan Ernst

The United States had tried diplomacy since late 2010 to free Army Sergeant Bowe Bergdahl, held captive in Afghanistan for nearly five years. But the efforts came to little until now.

Mistrust between Washington and the insurgents had blocked progress, U.S. officials said. So did the deep-seated fears of Afghan President Hamid Karzai that a deal between the Americans and the Taliban would undercut him and his fragile government.

Complicating the talks, U.S. officials said, was an internal split between Taliban factions willing to talk to Americans and those staunchly opposed.

After the details of earlier diplomatic efforts became public in late 2011, the Taliban’s leadership struggled to contain internal splits over a potential peace deal, U.S. officials said.

All of that changed in recent weeks - the exact time-frame is unclear - when Taliban hard-liners reversed position, officials said. The shift cleared the way for the dramatic pick-up of Bergdahl on Saturday by U.S. Special Operations forces in remote eastern Afghanistan and the freeing of five Taliban detainees, who flew aboard a U.S. military aircraft from Guantanamo to the Gulf emirate of Qatar.

U.S. officials, speaking on condition of anonymity, have long acknowledged a fragmented understanding of the Taliban’s internal politics.

But the Taliban’s reclusive leadership may have realized that this was their last and best chance to retrieve its prisoners.

Another contributing factor was presidential politics. Both contenders in the second round of Afghanistan’s presidential election, Abdullah Abdullah and Ashraf Ghani, have pledged to sign a Bilateral Security Agreement allowing a small U.S. force to stay after NATO combat operations end in December.

RENEWED HOPE FOR PEACE TALKS

The question now, two U.S. officials say, is whether the prisoner swap could lead to broader peace talks between the Taliban and the Afghan government for a negotiated end to the Afghan conflict.

The officials expressed hope that it might.

“We do hope that having succeeded in this narrow but important step, it will create the possibility of expanding the dialogue to other issues. But we don’t have any promises to that effect,” said one senior U.S. official deeply involved in the diplomacy.

After a five-month diplomatic freeze, last November the Taliban signaled to the United States, via intermediaries, its willingness to talk, the official said. Leaders made clear they were only willing to discuss a prisoner exchange.

In January, after the Taliban produced a “proof of life” video confirming Bergdahl was alive, U.S. negotiators told the Afghan fighters they would proceed with the swap.

Then the Taliban introduced a new roadblock, refusing to meet directly with the Americans. Envoys from Qatar would be present at every step, passing messages between the sides and ultimately escorting the five Guantanamo detainees aboard a U.S. Air Force C-17 cargo aircraft bound for the Gulf nation.

Many details about the talks remain unknown.

But some U.S. officials said the Americans were surprised at the deal’s speedy conclusion, after nearly four years of stalemate. U.S. President Barack Obama was regularly briefed, including while on a surprise Memorial Day weekend visit to Afghanistan last Sunday, a second senior U.S. official said.

At that moment, talks of prisoner releases, taking place in the Qatari capital of Doha, were entering what U.S. officials called their “terminal phase”.

Final arrangements were made for Berghdal’s release, and Obama on Tuesday spoke with Qatar’s emir, Sheikh Tamim bin Hamad al-Thani. The two personally reviewed and agreed on restrictions for the movements and activities of the Taliban prisoners.

The five are expected to live on compounds in Qatar, and their families will be brought there to live with them, officials said.

There are indications that the Taliban will be more willing to engage in peace talks with the Afghan government once Karzai leaves office, the officials said.

But given the tortured diplomatic path needed to release five Afghans and an American, those talks are likely to be difficult.