The United States has said that it did not believe Thailand's army had staged a coup but urged the military to respect democratic institutions.

Thailand's army today declared martial law nationwide to restore order after six months of street protests that have left the country without a proper functioning government.

"Martial law, the declaration of that, is allowed for in the Thai constitution," US State Department spokeswoman Jen Psaki told reporters after armed troops deployed across Bangkok.

"The army has stated publicly that it would be a temporary action. We expect them to abide by their commitment," Ms Psaki said.

Ms Psaki said that the US has been in regular contact with the Thai military and was "encouraging calm, encouraging protection of civil liberties and freedom of speech and freedom of media".

Thailand's army chief, meanwhile, has invited both sides of the kingdom's political divide to talks.

"We are in the process of inviting both sides to talk but at the minute the situation is still not normal... that's why I have had to invoke martial law," General Prayut Chan-O-Cha told reporters.

The army chief urged pro- and anti-government protesters not to clash, amid fears of widespread violence as the political crisis intensifies, and added martial law would be revoked after peace and order had been restored to the country.

Earlier the military said its action was not a coup.

Thailand remains bitterly divided between the largely rural supporters of self-exiled former premier Thaksin Shinawatra and the Bangkok-based establishment, and its southern royalist allies, who loathe him and want to end his dominance of Thai politics.

Months of anti-government protests have seen 28 people killed and hundreds more wounded in political violence.

Three people died in a gun and grenade attack on a rally site in Bangkok's historic centre by unknown assailants on 15 May.

"The military will not tolerate any more loss of lives," Gen Prayut said.

When asked if he intends to stage a military coup, in a nation which has seen nearly 20 successful or attempted coups, the general responded: "Don't jump to conclusions."

"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," Gen 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."

Provincial governors and top officials were summoned to meet 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.

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 former prime minister Yingluck Shinawatra, Mr Thaksin's younger sister, and nine of her ministers were dismissed on 7 May 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 Mr 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 Mr 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 Mr Thaksin's influence.

The government views an early general election it would likely win as the best way out.