The theft took just a few keystrokes _ a couple of numbers changed on a spreadsheet and suddenly one soldier's salary was dumped into another's bank account.
For a long time, no one noticed. The three Afghan army officers didn't divert the salaries of active duty soldiers. Instead they kept deserters on the books and directed their pay into their own accounts. Sometimes they diverted bonuses.
When 14 soldiers at a northern Afghan army base were eventually charged in the theft, about $22,000 had been stolen.
That's not much in Afghanistan, where millions disappear from aid projects, government contracts and training programs. But the case is especially worrying as the U.S. looks to start drawing down forces this summer because the theft occurred in one of the army's elite commando units _ using a system put in place precisely to prevent such fraud.
It's a reminder that turning the Afghan army into a professional fighting force will likely stretch far beyond the NATO allies' timeline to hand over control of security to the Afghan government by 2014.
Ten men were found guilty in a trial in April, and the three main conspirators received prison sentences of two to three years. All three plan to appeal.
Both Afghan officers and their American advisers praised the trial as proof that misconduct is being reined in.
"I'm upset that such an incident happened, but I'm glad that we are having the trial," said Defense Ministry spokesman Gen. Mohammad Zahi Azimi. "It is a lesson to others that anyone who steals in this way will end up in court."
The important thing, he said, is that the corruption was discovered and punished.
That almost didn't happen. If it weren't for the dogged pursuit by one military prosecutor, who withstood death threats and the anger of his superiors, the embezzlement would still be going on.
Lt. Abdul Wakil first became suspicious when an informant alerted him in late 2010 that money was somehow being stolen from the payroll at his base, the 5th Commando Battalion in Mazar-i-Sharif.
Wakil went to the commanding officer, Lt. Col. Mohammad Basir, with his suspicions. "He refused to listen. He said there was no problem," Wakil said.
Undaunted, Wakil started investigating on his own. As he examined the base's payroll documents, something strange popped out: The battalion never seemed to lose any soldiers.
Desertion is common in the Afghan army. Soldiers sign up for the mandatory three years, then leave whenever they've had enough. Sometimes they go AWOL for months, returning without explanation.
Normally a unit's payroll shows these fluctuations. But the 5th Commando Battalion had no deserters. No one ever left and came back in.
Then Wakil compared the electronic spreadsheet emailed to the bank with the official paper copy. The computer file was different. The deserters' bank account numbers had been changed to those of active duty soldiers.
Wakil took the evidence to his superiors and opened an investigation last June. It took months for him to follow the money trail and unravel who received the stolen funds and how much.
During that time, Wakil faced angry challenges from his superiors.
Basir, the commanding officer, said the allegations were impossible, and he seemed to have a point. The computerized direct-deposit system was set up precisely to prevent such fraud. Before, officers routinely skimmed off some of the rank-and-file's pay without soldiers ever realizing they were being cheated. Now salaries went directly into soldiers' bank accounts.
But, it turned out, there was another avenue for fraud.
"No one understands the banking system, so no one saw the problem," Wakil said.
As the investigation progressed, rumors started to fly about who might be charged.
Late one night, Wakil was awakened by a phone call. The caller said he knew about the investigation, then warned: "When you come out of the military court, we will kill you."
Wakil received three more death threats that week. Then he started getting threatening text messages. In one, the sender said he had enlisted 20 Taliban fighters to hunt Wakil down.
Wakil pressed on.
"These sort of things happen in Afghanistan," he said of the threats. "I have to do my job."
The head of the Afghan army's legal office in Kabul said corruption cases are notoriously difficult to pursue.
"The people who cheat the military, they are smart about it," Brig. Gen. Abdul Karim said. They know where the weaknesses are and the people to pay off. And it goes far beyond payroll theft, he said. Soldiers routinely sell weapons on the black market and bribe superiors for promotions.
And yet the army courts have pursued few corruption cases. Only about a dozen of the 783 cases heard in military courts in the past year involved corruption, Karim said. Most are for traffic violations, AWOL soldiers, lost weapons or immoral conduct, with an occasional serious crime like murder, he said.
Karim could recall only one other corruption case in which an officer was convicted: a colonel found guilty a year and a half ago of stealing $10,000 from a construction contract. He was sentenced to one year restricted to the base at reduced pay.
The convicted ringleaders in the Mazar-i-Sharif theft were the battalion's financial affairs officer, Lt. Col. Shamsudin, as well as two young sergeants under his command, Sgt. Ahmad Jawed and Sgt. Hemran.
Shamsudin received a three-year prison sentence, while Jawed and Hemran were sentenced to two years each. Seven others were convicted and ordered restricted to base for six months to one year at reduced salaries, including Lt. Col. Basir, who was convicted of negligence.
Shamsudin, Jawed and Hemran were fined $4,000, $19,000 and $7,400 respectively, fines the court said reflected twice the amounts they stole.
Jawed's attorney, Abdul Matin, said his client and the others were scapegoats and the case would not stop corruption in the military.
"Stealing money in the commando battalion is a reality," Matin said.
"The thought among the people is that this government we have is temporary. There may be another one in a few months or a few days," he said. "So everyone steals.
Associated Press Writer Amir Shah contributed to this report.