WASHINGTON: The US special envoy for Afghanistan and Pakistan is stepping down, Secretary of State John Kerry announced Wednesday in a move which comes at a key juncture in troubled US-Afghan ties.

James Dobbins, a veteran diplomat with deep ties to Afghanistan, is retiring after just over a year in office and will be replaced by his deputy Dan Feldman, Kerry said in a statement.

The shuffle comes as the two candidates to be Afghanistan's next president succeeding Hamid Karzai who has held the reins for 13 years, wrangle over alleged fraud in the elections.

The political crisis threatens the country's first democratic transfer of power, and tarnishes US hopes of a smooth handover as it prepares to withdraw all US forces by late 2016.

Dobbins's “relationship with President Karzai was invaluable, particularly at difficult moments,” Kerry said, announcing the departure of his special representative for Afghanistan and Pakistan.

The veteran diplomat, who came out of retirement to take up the post in May 2013, has steered negotiations to draw up a security pact to safeguard US troops staying in Afghanistan beyond this year.

After Karzai refused at the 11th hour to sign the deal, both presidential candidates said they would honor the negotiations and accept the bilateral security agreement (BSA).

US President Barack Obama announced in May that US forces would complete their withdrawal from Afghanistan in 2016, ending more than a decade of war which followed the 2001 US invasion to oust the hardline Islamic Taliban government.

The 32,000-strong US deployment in Afghanistan is to be scaled back to around 9,800 by the start of 2015.

Dobbins “has played an outsized role on the ground negotiating the BSA, making preparations for historic elections, growing our counterterrorism cooperation with Pakistan, and planning for a transition for the Afghan people after more than a decade of progress,” Kerry said.

He will be “forever known as the guy who raised the first flag over our embassy in Kabul after the fall of the Taliban,” Kerry added.

Feldman will now take over the post once held by the charismatic diplomat Richard Holbrooke, who had brought him on board as deputy special representative for Afghanistan and Pakistan in 2009.

Feldman is charged “with the same mandate as his esteemed predecessors: to align, focus, and implement policies and programs that support our national security interests in a secure, stable and prosperous Afghanistan and Pakistan,” Kerry said.