While troops patrolled the streets of Bangkok, the caretaker government led by supporters of self-exiled former premier Thaksin Shinawatra was still in office, military and government officials said. Ministers were not informed of the army's plan before the announcement on television at 3 a.m. (2000 GMT on Monday).
Army chief General Prayuth Chan-ocha said the military was taking charge of public security because of violent protests that had claimed lives and caused damage. Nearly 30 people have been killed since the protests began in November last year.
"We are concerned this violence could harm the country's security in general. Then, in order to restore law and order to the country, we have declared martial law," Prayuth said.
"I'm asking all those activist groups to stop all activities and cooperate with us in seeking a way out of this crisis."
Prayuth had invited directors of government agencies and other high-ranking officials to a meeting at 2 p.m. (0700 GMT), an army spokesman said. Provincial governors and top officials were summoned to met the army at regional centres.
Both pro- and anti-government protesters are camped out at different places in Bangkok and the army ordered them to remain where they were and not march anywhere to prevent clashes.
The army also called on media not to broadcast material that would affect national security.
The caretaker government, wary of the army given its past interventions on the side of the establishment, welcomed the move to restore order. It said it had not been informed but it was still running the country.
"The government doesn't have a problem with this and can govern the country as normal," caretaker Justice Minister Chaikasem Nitisiri, told Reuters.
An aide said caretaker Prime Minister Niwatthamrong Boonsongphaisan had summoned a government meeting at an undisclosed location to discuss the situation.
Thailand has been stuck in political limbo since Prime Minister Yingluck Shinawatra, Thaksin's younger sister, and nine of her ministers were dismissed on May 7 after a court found them guilty of abuse of power.
The crisis, the latest instalment of a near-decade-long power struggle between former telecoms tycoon Thaksin and the royalist establishment, has brought the country to the brink of recession.
The military, which put down a pro-Thaksin protest movement in 2010, has staged numerous coups since Thailand became a constitutional monarchy in 1932. The last one was in 2006 to oust Thaksin, who has lived abroad since 2008 but wields political influence and commands huge support among the poor.
Anti-government protesters want a "neutral" prime minister appointed to oversee electoral reforms aimed at ending Thaksin's influence. The government views an early general election it would likely win as the best way out.
The army tried to mediate in the crisis late last year, bringing together then premier Yingluck and anti-government protest leader Suthep Thaugsuban. It has played down fears of a coup, stressing that politicians must resolve the dispute.
But one analyst called Tuesday's army action a "phantom coup".
"There was no consultation with the government and I think the military will slowly expand its powers and test the waters," said Kan Yuenyong at the Siam Intelligence Unit think-tank.
"For this to be a success the army needs to act like a neutral force and not be seen to side with the anti-government protesters. It needs to offer an election date and start a political reform process at the same time."
The United States, which cut aid to its military ally after the 2006 coup, said it was monitoring the situation closely.
"We expect the army to honour its commitment to make this a temporary action to prevent violence, and to not undermine democratic institutions," said U.S. State Department spokeswoman Jen Psaki in a statement.
Army chief Prayuth had warned last week, after three people were killed in a gun and grenade attack on anti-government protesters in Bangkok, that troops might have to be used to restore order if the violence continued.
"The army chief was moving towards imposition of martial law ever since his announcement last week," said a senior army official, who spoke on condition of anonymity.
"He now feels that the police cannot handle security and is alarmed by grenade attacks and other incidents and the fact neither side looks like it will back down."
Troops stopped some morning traffic from entering the city and placed sandbags outside a city centre police headquarters, witnesses said. Soldiers had also secured television stations.
Ten satellite television channels, including stations run by pro- and anti-government groups, were ordered to stop broadcasting to "preserve peace and order".
"NO COUP YET"
The baht fell against the dollar in early trade but steadied later and dealers suspected that was due to intervention by the central bank. At 0500 GMT the baht was quoted at 32.475/515 per dollar after earlier trading at a low of around 32.64.
The stock market fell around 1 percent.
Six months of turmoil has dragged down Southeast Asia's second-biggest economy, which shrank 2.1 percent in the first quarter of the year.
Andrew Colquhoun, Head of Asia-Pacific Sovereigns at ratings agency Fitch, said martial law was not necessarily negative for Thailand's government debt, and might help break the deadlock.
"The key factors for the ratings are whether Thailand can avert more serious and bloody political disorder, and whether we see a return to a fully functioning government that is able to make policy and pass a budget for the next fiscal year starting in October," he said.
Opposition supporters disrupted a Feb. 2 election which was later declared void by the Constitutional Court. The protesters reject any vote before electoral reforms and the Election Commission has said it does not think a poll tentatively scheduled for July 20 can go ahead.
The leader of Thaksin's pro-government "red shirt" loyalists, who are rallying in Bangkok's western outskirts and who have warned of violence if the government was ousted, appealed for calm.
"Our stance is the same. (We) will not accept a neutral prime minister. If soldiers appoint a prime minister then we will escalate our rally," Jatuporn Prompan told a news conference. "Stay calm, there has been no coup yet."
Anti-government protesters said they too had not changed their demands for the caretaker government to go.