Related Rule
Israel
Practice Relating to Rule 107. Spies
Israel’s Manual on the Laws of War (1998) states:
The spy does not meet the conditions required of a legal combatant (since he is assimilated in the civilian population) and thus is not entitled to the prisoner-of-war’s immunity against being tried. Therefore, a state that captures a spy is allowed to bring him to trial in accordance with its own internal laws, an offense that is generally punishable by a long prison sentence or even death … A spy who has succeeded in completing his mission and returning to his army is once again entitled to legal combatant status. 
Israel, Laws of War in the Battlefield, Manual, Military Advocate General Headquarters, Military School, 1998, p. 59.
Israel’s Manual on the Rules of Warfare (2006) states:
Spying in itself is not an action that is prohibited in itself under the rules of war, and a country sending a spy into enemy territory is not in breach of international law. As has been shown, however, a spy does not meet the conditions required of a legitimate fighter (because he is hidden among the civilian population) and is consequently not entitled to the immunity from prosecution of a prisoner-of-war. A country that captures a spy is entitled to put him on trial under the domestic laws and sentence him to a long term of imprisonment or even to death (if the spy is a national of the country in which he was caught, the crime for which he may be tried may be treason, and not espionage).
The rules of The Hague Convention are also designed to protect the rights of a spy. A spy who has been caught is entitled to a trial, and as stated his punishment will be meted out under the internal laws of the country that caught him. A spy who has succeeded in fulfilling his mission and return to his army is entitled to return to the status of legitimate fighter, and if he becomes a prisoner-of-war (as a combatant) it is not permitted for him to be tried as a spy. 
Israel, Rules of Warfare on the Battlefield, Military Advocate-General’s Corps Command, IDF School of Military Law, Second Edition, 2006, p. 36.
The Manual on the Rules of Warfare (2006) is a second edition of the Manual on the Laws of War (1998).