(Adds comment from army chief, acting justice minister, details)
By Apornrath Phoonphongphiphat
BANGKOK, May 20 (Reuters) - Thailand's army declared martial law on Tuesday to restore order after six months of anti-government protests that have left the country without a proper functioning government, but denied that it was staging a military coup.
The caretaker government led by supporters of self-exiled former premier Thaksin Shinawatra was still in office, military officials and the country's justice minister said, following the surprise announcement on television at 3 a.m. (2000 GMT on Monday).
Army chief General Prayuth Chan-ocha later 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."
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. An acting prime minister has since taken over.
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, a billionaire who commands huge support among the rural poor.
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.
Although the caretaker government's supporters are wary of the army, given its past interventions on the side of the establishment, the acting justice minister said it welcomed the move to keep the peace.
"It's good that the army is looking after the country's security. However, the government still has full power to run the country," Chaikasem Nitisiri told Reuters.
TROOPS PATROL THE CAPITAL
Troops were patrolling in Bangkok, stopping some traffic from entering the city and placing sandbags outside a city centre police headquarters, witnesses said.
Soldiers had secured television stations, one Thai army general said.
"We declared a state of emergency, it's not a coup. Because of the situation, it's not stable, they kill each other every day," the general, who declined to be identified, told Reuters.
"We need cooperation from them to announce to the people 'do not panic, this is not a coup'," the general said.
Acting Prime Minister Niwatthamrong Boonsongphaisan on Monday ruled out resigning as a way out of a protracted political crisis that is stunting economic growth, as anti-government protesters stepped up pressure to remove him and install a new administration.
Six months of turmoil, including a disrupted general election and violent protests, is dragging down Southeast Asia's second-biggest economy, which shrank 2.1 percent in the first quarter of the year.
The anti-government protesters say the appointment of Commerce Minister Niwatthamrong as acting prime minister has no legal standing and they want an appointed, "neutral" government to push through reforms.
The government and its supporters view a general election as the best way to solve the crisis - the ruling Puea Thai Party would be well placed to win - but a vote tentatively scheduled for July 20 already looked unlikely to take place.
Jatuporn Prompan, leader of pro-government "red shirt" activists, said he and his followers would keep up their protest in Bangkok's western outskirts until the restoration of "democratic principles" leading to an election.
"That's fine," Jatuporn told Reuters when asked about his reaction to the declaration of martial law.
"We will stay here and continue our protest until the country is back to democratic principles, which will lead to an election and getting a new elected prime minister."
A Feb. 2 election was disrupted by opposition supporters and then declared void by the Constitutional Court. The protesters say they will disrupt any vote before changes to the electoral system are pushed through.
The anti-government protesters, who draw support from the Bangkok middle classes and are backed by the royalist establishment who see the populist Thaksin as a threat, said they would scale back planned demonstrations but still wanted the caretaker government out.
"We will not march today but we will stay and continue the protest until we achieve our goal," anti-government protest leader Sathit Wongnongtoey told Reuters.
Weak exports and the political mayhem have damaged the economy, prompting the state planning agency to cut its forecast for 2014 growth to between 1.5 and 2.5 percent, from a range of 3.0 to 4.0 percent. (Reporting by Bangkok Bureau; Writing by Robert Birsel and Dean Yates; Editing by Alan Raybould and Alex Richardson)