A U.S. soldier charged with desertion for leaving his unit in Iraq (search) contended Thursday at this court-martial that he did not commit a crime because the Army had improperly failed to discharge him.

Staff Sgt. Camilo Mejia (search), an infantry squad leader in the Florida National Guard, acknowledged disobeying his commanders' orders to return to Iraq in October after a two-week furlough.

Mejia said he asked to be discharged under a National Guard regulation barring non-U.S. citizens from serving more than eight years. Mejia, who joined the Army nine years ago, has dual citizenship in Costa Rica (search) and Nicaragua (search).

"I thought I had every right to be discharged, but the military for some reason did not want to uphold military law," Mejia said. "Because I did not think I had committed a crime, I looked for help outside the military."

Mejia, 28, of Miami Beach, was missing from the Army five months before he turned himself in March 15, seeking status as a conscientious objector. He faces up to a year in prison and a bad conduct discharge if convicted.

A jury of four officers and four enlisted soldiers will decide the case.

Military law defines desertion as leaving the military with no intention to return or to "avoid hazardous duty or to shirk important service."

Mejia testified for 90 minutes Thursday, responding calmly to sometimes pointed questions.

"Nobody in your chain of command officially said to you, 'Staff Sgt. Mejia, you're discharged from the military.' Did they?" Capt. A.J. Balbo, the lead prosecutor, asked at one point.

"No, sir," Mejia replied.

Mejia's attorneys rested their case after he left the witness stand.

Three members of his unit -- the 1st Battalion, 124th Infantry Regiment -- testified Mejia had been a fine officer under fire.

Spc. Oliver Perez acknowledged he was disappointed when Mejia left and never returned.

"As an NCO [noncommissioned officer], I don't believe it was a good example, no," Perez said. "It was a blow."

But he later added, "I would still put the trust of my life in him."

Prosecutors argued that Mejia betrayed his unit, leaving them as fighting intensified around their base in Ramadi and their numbers thinned as troops were wounded by explosives, gunfire and mortar rounds.

"It's about a squad leader who abandoned his men when they needed him the most," Balbo said.

The prosecution called one witness, Capt. Tad Warfel, who was Mejia's company commander. Warfel said the unit saw its numbers dwindle from 131 soldiers to 95, mostly because of troops wounded in action.

"The conditions in Ramadi worsened in our time over there," Warfel said.

Mejia testified he asked Warfel and their battalion commander for a discharge after National Guard officials told him of a regulation that non-citizens must be discharged after eight years.

When his commanders refused, ordering him to return to the war, Mejia sought help from civilian attorneys. He acknowledged spending the next five months in hiding, refraining from using his credit cards or cell phone.

Mejia testified his war experience had convinced him he no longer wanted to fight.

"I did have problems in Iraq," Mejia said. "I don't believe I'm allowed to speak about these things here, but I did not agree with many things."

When he turned himself in March 15, Mejia said he was upset at seeing civilians hit by gunfire and at seeing an Iraqi boy die after confusion over which military doctor should treat him.

In his objector application, filed March 16, he also claims he saw Iraqi prisoners treated cruelly when he was put in charge of processing detainees last May at al-Assad, an Iraqi air base occupied by U.S. forces.

Mejia's conscientious objector application is being considered separately from his court-martial on the desertion charge.