The White House has given an ultimatum to Afghanistan’s rival presidential candidates: Resolve the dispute over last month’s election, or the United States will move forward with plans for immediate withdrawal of all U.S. forces from the war-torn nation by the end of the summer, sources told TheBlaze.

President Barack Obama has tasked Secretary of State John Kerry with resolving the election crisis after failed attempts by Senate Armed Services Committee Chairman Carl Levin (D-Mich.) to yield any resolution between former Finance Minister Ashraf Ghani Ahmadzai and his opponent, former Foreign Minister Abdullah Abdullah, a U.S. military official and a U.S. government official told TheBlaze

In this Monday, Aug. 27, 2012 photo provided by the U.S. Army, U.S. soldiers from the 4th Brigade, 82nd Airborne arrive to a yard where they will turn in their vehicles and equipment as part of drawdown of 23,000 U.S. troops by Sept. 30, 2012 at the Kandahar Air Field south of Kabul, Afghanistan. The U.S. military has started the process of moving out thousands of MRAPS, Humvees and other vehicles as part of the drawdown of 23,000 U.S. troops by the end of September. It is a massive logistical undertaking involving several yards on bases around the country. Credit: AP

In this Monday, Aug. 27, 2012 photo provided by the U.S. Army, U.S. soldiers from the 4th Brigade, 82nd Airborne arrive to a yard where they will turn in their vehicles and equipment as part of drawdown of 23,000 U.S. troops by Sept. 30, 2012 at the Kandahar Air Field south of Kabul, Afghanistan. (AP)

Both candidates have raised allegations of extensive election fraud, but Levin’s failure to resolve the crisis “is why Kerry arrived hastily” in Afghanistan early Friday, the U.S. official said.

“Kerry was given specific direction that if he did not resolve the election matter this weekend then we not wait any longer,” the military official said. “It would then be drop everything, massive immediate withdrawal of all personnel. If we just pull everyone out and let it collapse to infighting between regional warlords and ethnic-driven governance, then what was the point of the surge or the last six years when our casualties skyrocketed? We could have done that in 2009, and saved thousands of troops and billions of dollars.”

Kerry told reporters Friday that the United States is “in a very, very critical moment for Afghanistan.”

“Legitimacy hangs in the balance. The future potential of the transition hangs in the balance. So we’ve a lot of work to do,” Kerry said, according to the Associated Press.

A complete withdrawal after 13 years of war is a contingency plan the Obama administration would like to avoid, but one it will move forward with if either of the candidates declares himself the winner and tries to establish a government before the United Nations conducts an investigation into the fraud allegations, the government official said.

Afghan presidential candidate Abdullah Abdullah, center, shakes hands with U.S. Secretary of State John Kerry at the start of a meeting at the U.S. Embassy in Kabul, Friday, July 11, 2014. Kerry sought Friday to broker a deal between Afghanistan's rival presidential candidates as a bitter dispute over last month's runoff election risked spiraling out of control. (AP Photo/Jim Bourg, Pool) AP Photo/Jim Bourg, Pool

Afghan presidential candidate Abdullah Abdullah, center, shakes hands with U.S. Secretary of State John Kerry at the start of a meeting at the U.S. Embassy in Kabul, Friday, July 11, 2014. Kerry sought Friday to broker a deal between Afghanistan’s rival presidential candidates as a bitter dispute over last month’s runoff election risked spiraling out of control. (AP Photo/Jim Bourg, Pool)

State Department officials in Washington, D.C., said they could not comment on the circumstances surrounding the negotiations.

White House National Security Council spokeswoman Caitlin Hayden told TheBlaze she would not comment on conjecture about withdrawing forces or on directives from the White House. She said Kerry is in Kabul meeting with the U.N. and with Abdullah, Ghani and outgoing leader, President Hamid Karzai, to resolve the crisis.

“The secretary is reinforcing the president’s message that we expect a thorough review of all reasonable allegations of fraud and that we will not accept any extra-constitutional measures to resolve the situation, which would result in the end of U.S. assistance to Afghanistan,” Hayden said. ”All parties should avoid steps that undermine Afghan national unity and should come together to work toward a resolution that represents the will of the Afghan people and produces a government that can bring Afghanistan together.”

For the White House, the failure to resolve the crisis in Afghanistan and the continuing disintegration of Iraq at the hands of Islamic extremists would leave Obama with a failed legacy regarding the wars he inherited from the Bush administration, said James Carafano, a senior defense analyst with the conservative Heritage Foundation think tank.

“If Obama winds up pulling the plug on Afghanistan to avoid another Alamo, there will be a lot of ‘I told you so’ from critics of the administration’s policies,” Carafano said. “Obama’s surge was a half-measure that many warned wouldn’t be decisive. Setting hard timelines for withdrawal emboldened the Taliban and weakened support for U.S. policies in Afghanistan. The draw-down was premature and put all our remaining forces at risk. They played to lose. So this doesn’t come as much of a surprise.”

Officials: If Kerry Cant Broker Deal In Afghanistan, Obama Will Move for Massive Immediate Withdrawal of All Personnel

Afghan election commission workers carry plastic ballot boxes at a warehouse in Jalalabad, June 12, 2014. (Noorullah Shirzada/AFP/Getty Image

Obama first announced in December 2009 the U.S.’ intent to withdraw, a decision for which he was sharply criticized by many U.S. lawmakers, who said he was emboldening the Taliban to simply hold tight and recruit more fighters.

The White House, however, defended the decision to announce the drawdown of the majority of U.S. troops from the region by 2011, saying it needed leverage to push Karzai’s government to take more responsibility for its own nation and internal strife.

“The administration could well claim it’s doing it’s best in a bad situation, but it will gloss over as it did in Libya, Syria, Ukraine, Iraq, and on the U.S.-Mexico border that the bad situation was in large part the result of really bad policy decisions in Washington that came out of the Oval Office,” Carafano said.

For the United States, the political crisis threatens to undermine more than a decade of efforts to leave behind a strong Afghanistan capable of containing the Taliban insurgency and preventing extremist groups like Al Qaeda from using the territory to endanger the American homeland.

Abdullah nor Ghani could be immediately reached for comment.

“A transitional government must be formed for one year and the independent electoral commission must be also reformed,” Mohammad Mohaqeq, one of Abdullah’s vice presidential candidates, told Bloomberg News. He was referring to a scenario where Abdullah rejects the final results. “And then a re-election should take place nationwide.”

The standoff threatens to delay an agreement that would allow U.S. troops to remain in the country after this year and bring in aid money needed to fund soldiers fighting a Taliban insurgency. Kerry and Obama have warned that any attempt to form a government outside the constitutional process would result in the U.S. cutting off economic and military aid.

Abdullah told this reporter in 2011 that the “Islamic Republic of Afghanistan represents the majority will in this Muslim country — the will of the people in voting, general elections and many things which come with it.”

He warned that “the Islamic Emirate, which is the Taliban, want an emir. They have no boundaries, the whole world is their territory and anybody who believes in this ideology is a Talib, whether it is an American Talib, British Talib, all of them are called Taliban and the terrorists from all around the world are part of it. So the battle is between the two.”

According to the AP, Kerry said the United States wants a process by which the rightful leader to emerge is viewed as legitimate, but admitted, “I can’t tell you that’s an automatic at this point.”

Follow Sara A. Carter (@SaraCarterDC) on Twitter

Other Must-Read Stories