The military also prohibited “all media outlets from the reporting or distribution of any news or still photographs detrimental to national security.” And protest groups for and against the government were barred from leaving circumscribed areas, an order that seemed to contradict the initial order for them to “stop” their movement but also was praised as a sign that the military would not clamp down on civil liberties.

General Prayuth said martial law had been imposed “in order to keep peace and order efficiently and to bring back peace to the people.”

Thailand’s Constitution allows for martial law. But in his declaration on Tuesday, General Prayuth cited a 1914 law passed while Thailand was still an absolute monarchy. The law requires that a royal proclamation be issued before martial law is announced. General Prayuth did not say whether he had sought the assent of King Bhumibol Adulyadej, who is ailing.

In his speech the general cited “ill-willed people who created violence by using weapons of war” for his decision. More than 25 people have been killed in political violence since the protests began six months ago.

A separate statement issued later in the morning appeared to strip the government of some of its security powers. The statement said the government’s security unit, the Center for the Administration of Peace and Order, had been dissolved and replaced by a military-staffed organization.

A movement to oust the government has the backing of the Bangkok establishment and is seeking to put in place an appointed prime minister. Led by a former opposition politician, Suthep Thaugsuban, the movement has obstructed elections and is seeking the removal of the country’s caretaker government. Until now, the military has said it will not take sides between the protest movement and the caretaker government. But legal experts say the military has already chosen sides because it has a duty to take orders from the elected government.

The antigovernment movement has shut down government buildings and continues to occupy the prime minister’s office. The courts have issued numerous favorable rulings to the movement, including the removal of Prime Minister Yingluck Shinawatra earlier this month and an order barring the dispersal of the protests.