KABUL, Afghanistan  — Afghanistan’s election stalemate this summer hurt progress in training the country’s military, and resolving the political chaos will be key to that military’s success in 2015, Marine Gen. Joseph Dunford said as he stepped down as the top U.S. commander in Afghanistan.

The Taliban will test the Afghan forces next year with an onslaught of fighters and attacks, hoping to capitalize on the dwindling U.S. and coalition troops in the country, Dunford said Tuesday, Aug. 26.

Shortly after he passed the flag to his successor, Army Gen. John Campbell, during a ceremony in Kabul, Dunford ended his 18-month tour and boarded a plane back to the U.S. His tenure at the battlefront spanned a critical transition period for the war, as the Obama administration announced a sharp drawdown in U.S. troops to wind down the conflict, while the Afghans struggled to put a new government in place.

Earlier this year, Afghan forces were growing more confident as they set up security for the April election, then again for the runoff. But amid widespread accusations of election fraud, the two presidential finalists are awaiting the results of an audit to determine the winner, while continuing to argue about the tally’s legitimacy.

“As we went to political stalemate, we lost a little bit of the wind in their sails,” Dunford said, adding that the Taliban took advantage of that and launched a series of attacks across the south. “They were looking for a place to actually get a psychological victory to reinforce … the pessimism that followed the second round of elections.”

While the Afghan forces fought back and regained ground and a bit of the momentum, Dunford said the Taliban will mount another assault next summer.

“If we have a good political transition, that will propel the Afghan forces into 2015,” said Dunford, who is becoming the next commandant of the Marine Corps.

That smooth transition in Afghanistan, however, is still in doubt.

The April 6 voting to elect a successor to President Hamid Karzai resulted in a runoff between former Foreign Minister Abdullah Abdullah and ex-Finance Minister Ashraf Ghani Ahmadzai.

Abdullah received the most votes in the first round but failed to get enough to win. Ghani Ahmadzai appeared to be ahead in the runoff but both men have claimed fraud, and Abdullah is now threatening to pull out of the election audit.

If the dispute drags on, and there is no Afghan leader to sign a key U.S. security agreement, all American forces will be withdrawn at the end of this year. Such a withdrawal would disrupt ongoing U.S. efforts to advise and equip the Afghan military. And it could demoralize the Afghan forces and fuel the Taliban’s fight.

Campbell agrees that the political disarray may have an impact on the Afghan fighting force. In an interview at his headquarters, he said he planned to evaluate what impact the election stalemate has had on the military transition and the effort to draw down and redistribute the U.S. forces. He said he wanted to determine whether the political problems have delayed the Afghans’ progress and if any adjustments must be made.

Others suggest that even if the politics settle down and the agreement is signed, Campbell would still face some difficult challenges, including a troop withdrawal plan outlined by President Barack Obama that would leave about 9,800 U.S. military personnel in Afghanistan at the end of this year, half that by the end of 2015 and just 1,000 in a security office there after 2016.

James Stavridis, former top NATO commander and the dean of the Fletcher School of Law and Diplomacy at Tufts University, said Campbell will have to maintain the confidence of the Afghan security forces during the transition, ensuring that the Taliban doesn’t establish a territorial foothold.

He said it was a mistake for the administration to be so definitive about the 2016 date for a full troop withdrawal, saying events on the ground should govern when the U.S. should depart. “It does nothing but give hope to the Taliban,” he said.

Stephen Biddle, a professor of international affairs at George Washington University, said the dwindling number of American troops will translate into less U.S. influence over the country as it moves forward.