Martial law
The President decides on the declaration of martial law and then Verkhovna Rada must approve it.
Martial law was first declared in Ukraine in 2018 and as a response to Russian hostilities. On 26 November 2018, lawmakers in the Verkhovna Rada overwhelmingly backed President Petro Poroshenko's imposition of martial law along Ukraine's coastal regions and those bordering the Russian Federation and Transnistria, an unrecognized breakaway state of Moldova which has Russian troops stationed in its territory, in response to the firing upon and seizure of Ukrainian naval ships by Russia near the Crimean Peninsula a day earlier. A total of 276 lawmakers in Kyiv backed the measure, which took effect on 28 November 2018 and automatically expired in 30 days.
This period of martial law was both intended to be, and ultimately was, limited in scope. Then-president Poroshenko proposed a 60-day martial law period, but ultimately a 30-day period of martial law was signed into effect. This period of martial law came to an end at its scheduled 30-day mark. This declaration was limited to specific areas of Ukraine, including territories along the Russia-Ukraine border, the Moldova-Ukraine border, the coasts of the Black Sea, the Sea of Azov, and the Azov – Kerch international waters.
On 24 February 2022, President Volodymyr Zelensky declared martial law in response to the Russian invasion of Ukraine. Then, on 15 March, the Parliament of Ukraine adopted the Law of Ukraine "On Organizing Labor Relations under Martial Law" which came into effect on March 24, 2022, and "clarified relevant restrictions of the constitutional right and freedoms and set out special rules applicable to labor relations to replace the 'normal' rules of the Labour Code of Ukraine." Article 4(7) of the Law of Ukraine holds that the "General Staff of the Armed Forces of Ukraine shall direct, coordinate and control the activities of regional military administrations on defense, public safety, and order, and implement measures of martial law. The Cabinet of Ministers of Ukraine shall direct, coordinate and control the regional military administrations regarding other issues."
As of November 2023, there have been ten extensions to the Ukrainian declaration of martial law. This has led to the 2023 legislative and 2024 presidential elections being delayed, due to elections not being allowed to be held in times of martial law.

United States: In the United States martial law has been declared for a state or other locality under various circumstances including after a direct foreign attack (Hawaii after the Japanese attack on Pearl Harbor; New Orleans during the Battle of New Orleans); after a major disaster (Chicago after the Great Chicago Fire of 1871; San Francisco after the earthquake of 1906); and in response to chaos associated with protests and mob action (San Francisco during the 1934 West Coast waterfront strike; Montgomery, Alabama, following the mob actions against the Freedom Riders). It has also been declared by renegade local leaders seeking to avoid arrest or challenges to their authority (Nauvoo, Illinois by Joseph Smith during the Illinois Mormon War and Utah by Governor Brigham Young during the Utah War).
The martial law concept in the United States is closely tied with the right of habeas corpus, which is in essence the right to a hearing on lawful imprisonment, or more broadly, the supervision of law enforcement by the judiciary. The ability to suspend habeas corpus is related to the imposition of martial law. Article 1, Section 9 of the U.S. Constitution states, "The Privilege of the Writ of Habeas Corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it."  There have been many instances of the use of the military within the borders of the United States, such as during the Whiskey Rebellion and in the South during the Civil Rights Movement, but these acts are not tantamount to a declaration of martial law.
In United States law, martial law is limited by several court decisions handed down between the American Civil War and World War II. In 1878, Congress passed the Posse Comitatus Act, which, depending on the circumstances, can forbid U.S. military involvement in domestic law enforcement without congressional approval.(18 U.S.C. § 1385, original at 20 Stat. 152)
The legality of the implementation of martial law was examined in 1866, in the court case Ex parte Milligan, 71 U.S. 2 (1866). Through this case, the Supreme Court established that trying civilians in military tribunals was unconstitutional unless there were no civilian courts available. Today, the ability to declare martial law over the United States is not explicitly granted in the Constitution. Despite this, martial law has been declared at least 68 times in the United States.
There are two main schools of thought regarding the declaration of martial law. First, some scholars argue that the ability to declare martial law is a constitutional power vested in Congress, and in some cases of emergency, the President. The second school of thought believes that the power to declare martial law in the United States is not expressed in any law, but rather arises as a matter of necessity and in the interests of "national self-preservation." As it stands today, there is no explicit provision in the Constitution granting powers to any specific body of government to declare martial law.
Historically, martial law has been declared in response to national emergencies in the United States. In Hawaii, for example, martial law was instituted following the attack on Pearl Harbor. The Supreme Court evaluated the legality of declaring martial law in Hawaii in the court case Duncan v. Kahanamoku, 327 U.S. 304 (1946). Here, the Supreme Court held that although Hawaii was not yet a state, the legality of declaring martial law must be analyzed as though Hawaii was one. As a result, the United States determined that the safety of the residents of Hawaii was their responsibility, and martial law was implemented throughout the Hawaiian Islands.

Yugoslavia: During the Yugoslav Wars in 1991, a "State of Direct War Threat" was declared. Although forces from the whole SFRY were included in this conflict, martial law was never announced, but after secession, Croatia and Bosnia and Herzegovina declared martial law. On 23 March 1999, a "State of Direct War Threat" was declared in Yugoslavia, following the possibility of NATO air-strikes. The day after strikes began, martial law was declared, which lasted until June 1999, although strikes ended on 10 June, following Kumanovo Treaty.

See also: DEFCON
Gendarmerie
Military rule (disambiguation)
Stratocracy, a form of government headed by military generals.
Police state, state governed through the power of the police force.
Military junta, a government led by a committee of military leaders.
Military dictatorship, a form of autocratic rule led by the military.
Authoritarianism, a form of government with strong central power and limited freedoms.

References: 

Further reading: Macomb, Alexander, Major General of the United States Army, The Practice of Courts Martial, (New York: Harper & Brothers, 1841) 154 pages.
Macomb, Alexander, Major General of the United States Army, A Treatise on Martial Law, and Courts-Martial as Practiced in the United States. (Charleston: J. Hoff, 1809), republished (New York: Lawbook Exchange, 2007). ISBN 978-1-58477-709-0.
Rehnquist, William H. (1998). All the Laws but One: Civil Liberties in Wartime. New York: William Morrow & Co. ISBN 0-688-05142-1.
The Concise Oxford Dictionary of Politics. Edited by Iain McLean and Alistair McMillan, Oxford University Press, 2004. 
Black's Law Dictionary: Definitions of the Terms and Phrases of American and English Jurisprudence, Ancient and Modern. Henry Campbell Black. St. Paul: West Pub. Co., 1979.

External links: 
'Martial law' in the Encyclopædia Britannica
Martial law in Thailand in 2005
Full text of the 1972 Martial Law in the Philippines
NSPD-51
Emergency Rule of 3 November 2007 Pakistan Archived 16 September 2019 at the Wayback Machine