BANGKOK — Thailand’s army declared martial law before dawn Tuesday in a surprise announcement it said was aimed at keeping the country stable after six months of sometimes violent political unrest. The military, however, denied a coup d’etat was underway.

The move effectively places the army in charge of public security nationwide. It comes one day after the Southeast Asian country’s caretaker prime minister refused to step down and follows six months of anti-government demonstrations that have failed to oust the government.

Armed troops entered multiple private television stations in Bangkok to broadcast their message and surrounded the national police headquarters in the city center. Army jeeps mounted with a machine-guns diverted traffic on a major road in front of Central World, one of the country’s most luxurious shopping malls. But the vast metropolis of 10 million people appeared calm.

An army official said “this is definitely not a coup. This is only to provide safety to the people and the people can still carry on their lives as normal.”

A ticker on Chanel 5, an army station, also denied the military was taking over and asked the public not to panic.

Thailand’s army has staged at 11 successful coups since the end of absolute monarchy in 1932. The last was in 2006.

Thailand, an economic hub for Southeast Asia, has been gripped by off-and-on political turmoil since 2006, when former Prime Minister Thaksin Shinawatra was toppled by a military coup after being accused of corruption, abuse of power and disrespect for King Bhumibol Adulyadej.

The latest round of unrest started last November, when anti-government protesters took to the streets to try to oust then-Prime Minister Yingluck Shinawatra, Thaksin’s sister.

Earlier this month, the Constitutional Court ousted Yingluck and nine Cabinet ministers earlier this month for abuse of power, but the move has done little to resolve the political conflict that largely pits the rural poor majority who support Yingluck and her opponents that largely come from the urban middle and upper class.

The military statement was signed by army chief Gen. Prayuth Chan-Ocha, who later read it on air. He cited a 1914 law that gives the authority to intervene during times of crisis, and said it had taken the action because on-going mass rallies between political rivals “could impact the country’s security and safety of the lives and public property.”