Martial law is the system of laws and rules that take effect (usually after a formal declaration) instead of ordinary laws when a particular situation requires that a military authority takes control of the normal administration of justice (and usually of the whole state).
Martial law is instituted in a number of cases in which it becomes necessary to favour the activity of military authorities and organs, usually for urgent unforeseen needs, and when the normal institutions of justice cannot function ordinarily or when their ordinary procedures and rules could reveal too slow or to weak for the new situation, i.e. due to war or civil disorder, in occupied territory, or after a coup d'etat. The need to preserve the public order during an emergency is the essential goal of Martial law, with many potential accessory purposes.
Usually Martial Law contains a reduction of some of the personal warranties ordinarily granted to the citizen, limits the length of the trial processes and prescribes more severe penalties than ordinary law. In many countries Martial law prescribes death penalty for determined crimes, even if ordinary law doesn't contain that crime at all in its system.
In United States law, martial law is limited by several court decisions decided during the American Civil War and World War 2. In Ex Parte Milligan 71 US 2 1866, the United States Supreme Court ruled that martial law could not be instituted within the United States when the civilian courts are in operation.
In Canada in 1970, Prime Minister Pierre Trudeau invoked the War Measures Act in response to a terrorist kidnapping incident called the October Crisis which imposed a variant of martial law on the country.
Martial law was introduced in Poland by the Communist regime on December 13 1981 in order to prevent the democratic movements (such as Solidarity) from gaining popularity and thus power around the country. Many democratic leaders, including Lech Walesa, were imprisoned. This state of affairs lasted for two years.