A former commander of U.S. and NATO forces in Afghanistan said on Wednesday that corruption, not the Taliban, is the worst threat to the future of the war-torn country.

"For too long we focused our attention solely on the Taliban as the existential threat to Afghanistan," Ret. Gen. John Allen told a Senate subcommittee. Compared to the scope and the magnitude of corruption, "they are an annoyance."

Allen framed his opening remarks to the lawmakers in the form of a letter to the winner, who has not yet been determined, of the recent Afghan presidential election.

"While the Afghan National Army will battle your nation's foes and, in that context, battle the Taliban, the battle for Afghanistan — the real fight — will be won by righteous law enforcement, a functioning judiciary and an unambiguous commitment to the rule of law," Allen said.

"Wresting back the institutions of governance from corruption must be one of your highest priorities. ... Corruption is the dry rot of democracy."

Allen reiterated his recommendation that 13,600 U.S. troops and about 6,000 other international forces stay in Afghanistan after the NATO combat mission ends in December. The Afghan forces need the help to improve their leadership skills and technical know-how, which will allow them to mitigate the threat from the Taliban going forward, he said.

The Pentagon made a similar point in a report to Congress on Wednesday that said continued international military support for Afghanistan after 2014 "will be critical" to sustaining Afghan forces.

The Pentagon report, which described developments from Oct. 1, 2013 through the end of March, said that despite battlefield successes against the Taliban, the Afghan forces face what the Pentagon called four "critical high-end capability gaps." They are: air power, intelligence operations, commando operations and the ability of Afghan government ministries to sustain security forces.

The report also said that while Al-Qaeda is unable to use Afghanistan as a platform from which to launch transnational terrorist attacks, the group's relationship with Afghan Taliban leaders remains intact and is "an area of concern."

Allen also urged the next Afghan president to repair relations with the United States, which have been badly damaged by Afghan President Hamid Karzai's unwillingness to sign a bilateral security agreement with the U.S. And he called on the new president to make Afghanistan business-friendly, reach out to Pakistan and protect the rights of women and civil society.

Allen's testimony echoed a 260-page report issued Wednesday by the special inspector general for Afghanistan reconstruction. The report said that more than a decade of work financed with American tax dollars is at stake if bribery and theft are left unabated in Afghanistan.

Widespread corruption hampers the government's ability to collect revenue and hinders economic development and the effort to promote accountability, the quarterly report said.

"The costs in Afghanistan — both in lives lost and money spent — have been enormous," Special Inspector General John Sopko said in the report.

"If we don't take advantage of this opportunity and get serious about corruption right now, we are putting all of the fragile gains that we have achieved in this — our longest war — at risk of failure."

The Special Inspector for Afghanistan Reconstruction (SIGAR) report (PDF) says corruption is affecting all levels of customs collection, a revenue stream that could help Afghanistan become less dependent on international assistance. The report said U.S. agencies estimate that tens of millions of dollars are lost to smuggling each year and that stemming corruption "could potentially double the customs revenues remitted to the central government."

Between December 2012 and December 2013, Afghanistan missed its $2.4 billion revenue collection target by nearly 12 percent and reportedly could miss this year's target of $2.5 billion by as much as 20 percent, the SIGAR report said.

"This would mean that the Afghan government will only be able to pay for about a third of its $7.5 billion budget. It will depend on the international community to cover the shortfall," according to the report.

The U.S. has allocated at least $198 million to help Afghanistan collect customs revenue. Efficiency and collections have been improved at various sites, including the Kabul International Airport, but corruption still permeates all levels of the process, the report said.

Progress has been slow in setting up an electronic payment system, and customs fees in Afghanistan continue to be collected in cash. This requires customs brokers to travel long distances with large quantities of cash to pay the fees, leaving brokers vulnerable to theft and increases opportunities for corruption.

Al Jazeera and The Associated Press