After 9-11, the United States declared war. We didn't declare war on an enemy state; we declared war on a concept - terrorism. The president entered us into this war under his Constitutional warmaking authority pursuant to an AUMF signed by Congress. Our goal is to eliminate terror, specifically, Al Qaeda, who was deemed (and later corroborated) to be responsible for the attacks on September 11. One aspect of war is capturing enemy combatants. We captured a lot of people we declared were Al Qaeda members or Al Qaeda supporters, and we held them in, among other places, Guantanamo Bay, in Cuba. There, the detainees have been held without the right to challenge their detention, without the right to see the evidence against them, without the right to see the witnesses against them, they are subject to harsh treatment (at one time torture, perhaps, as well), and are subject to coerced confessions, which can be used against them in trial - trials that will be for their lives, for losing their case almost inevitably will result in death. Winning just means they get to go back to Guantanamo Bay, but that's for a different time.
The United States has sent the message to the world that this is how it treats those it captures pursuant to the laws of war. Common article 3 of the Geneva Conventions apply here; the president can't invoke the law of war for the capture and prosecution of enemy combatants and then claim a loophole that allows him to not offer the protections granted by the laws of war (gotta take the bitter with the sweet - one of the major holdings in Hamdan). We have told the world, as the superpower, that we consider this treatment to be acceptable.
A short time ago, 15 british Marines were captured by Iran. They were detained without access to international aid, they were subject to coerced confessions, and they were paraded over the airwaves. Iran had the confessions from the sailors, that they were violating Iranian waters. Iran had a violation of the laws of war, they had a confession, and we really were not in a position to forcefully say "you can't execute them," because that is what we hope to do with the few (I think 10?) detainees currently awaiting trial using coerced confessions as a principal piece of evidence. Yet, they didn't do so. They released the sailors - and there was much rejoicing.
People will argue that Iran had to do this, that it had no other viable choice, because executing the sailors would have invited retaliation, and perhaps that's true, but who would have been the aggressor? Per our actions in the war on terror, said executions would arguably have been justified. The western nations that attacked Iran would be punishing Iran for following the United States' lead.
While one could argue releasing the sailors was the "only" choice, it certainly was the best choice for Iran and the rest of the world. And for all the hateful rhetoric that Ahmedinejad spews, in this instance, he set the proper example.