* Court endorses emergency rule; warns against dispersing peaceful protests
* About 3,000 protesters rally at prime minister's temporary HQ
* Army spokesman urges both sides to avoid confrontation
* Election Commission to try to re-run some disrupted polling on March 2 (Updates with court ruling, police comment, Election Commission)
By Amy Sawitta Lefevre and Apornrath Phoonphongphiphat
BANGKOK, Feb 19 A Thai court endorsed on Wednesday Prime Minister Yingluck Shinawatra's declaration of a state of emergency, a day after five people were killed in gunbattles in Bangkok, but warned the government not to use it to disperse peaceful protesters.
The country's police chief said the court ruling would not affect the security operation, but added that there were no plans to retake more protest sites after Tuesday's "Peace for Bangkok Mission" saw the deadliest clashes since anti-government demonstrations began in November.
Yingluck, seen by opponents as a proxy for her brother, ousted former premier Thaksin Shinawatra, has been working from a Defence Ministry compound in north Bangkok since the protests forced her to vacate her Government House offices.
Protesters who want to drive her from office and eradicate Thaksin's influence surrounded the building on Wednesday, but there were no clashes with troops standing guard and Yingluck and other ministers stayed away.
The Civil Court in Bangkok dismissed a case brought by protest leaders who wanted a 60-day state of emergency announced last month declared illegal, but added that the government was "not allowed to use clauses in the state of emergency to disperse the protests".
The protests are the latest instalment of an eight-year political battle broadly pitting the Bangkok middle class and royalist establishment against the mostly rural supporters of Yingluck and Thaksin.
Problems continue to mount for Yingluck, after an anti-corruption agency filed charges against her over a soured rice subsidy scheme that has stoked middle-class anger and left hundreds of thousands of farmers, her natural backers, unpaid.
Shares in Thai property developer SC Asset Corp fell more than 4 percent after protesters said they would target assets linked to her wealthy family. The Shinawatra's own about 60 percent of SC Asset.
STATE OF EMERGENCY
The state of emergency, which covers Bangkok and surrounding provinces, allows security agencies to impose curfews, detain suspects without charge, censor media, ban political gatherings of more than five people and declare areas off-limits.
"This court ruling means we can't disperse protesters but we were never intending to anyway," national police chief Adul Saengsingkaew told Reuters.
"We are trying to arrest people who have arrest warrants, including leaders of the protest movement, and our strategy is to ask for protest sites back through negotiations."
A spokesman for the military, which has said it would intervene if police were unable to maintain security in the capital, appealed for both sides to avoid confrontation.
"Our strategy has not changed and is still to provide support to police," Colonel Werachon Sukondhapatipak told Reuters. "We have no intention of deploying extra troops. If the government needs extra help with security, it has to ask us and so far it has not asked for reinforcements."
The military has remained aloof from the latest crisis, but has a long history of intervening in politics.
Violence flared on Tuesday as police made their most determined effort since the start of the protests to reclaim sites around government buildings occupied for weeks. One police officer and four protesters were killed by gunfire.
Police said they came under attack from gunfire and grenades. Protest leaders accused police of opening fire on demonstrators.
Tarit Pengdith, head of the Department of Special Investigation, Thailand's equivalent of the FBI, insisted on Wednesday that security forces had not used live ammunition.
"The pictures you saw of police holding guns, those guns are used to fire rubber bullets only," he told a news conference.
News footage from the protests mostly showed police using shotguns that can fire rubber bullets. A few officers also carried military-style rifles, although it was unclear from footage whether these were fired.
Thai politics has been gripped by growing paralysis since Yingluck called a snap election in December.
Disruption by protesters meant voting could not be completed in the Feb. 2 poll, leaving Yingluck at the head of an enfeebled caretaker administration amid uncertainty over when a new government can be installed.
The Election Commission said it would try to hold elections on March 2 in five provinces where voting was disrupted. The commission will ask the Constitutional Court to rule on what to do with 28 districts in the south where candidates were unable to register.
Demonstrators accuse Yingluck's billionaire brother Thaksin of nepotism and corruption and say that, prior to being toppled in a 2006 coup, he used taxpayers' money for populist subsidies and easy loans that have bought him the loyalty of millions in the populous north and northeast.
The protesters, who are still blocking major intersections in central Bangkok, want to suspend what they say is a fragile democracy under Thaksin's control and eliminate his influence by altering electoral arrangements.
Adding to the crisis, a flagship rice programme that paid farmers way above the market rate has proved ruinously expensive and the caretaker government lacks the power to keep funding it.
A state bank had to cancel a loan that might have helped prop up the scheme in the face of a revolt by depositors who began pulling their money out.
Three Government Savings Bank branches in Bangkok contacted by Reuters on Wednesday morning said they were no longer seeing unusual numbers of customers withdrawing funds.
Thailand's anti-corruption body began an investigation last month into the rice scheme and said on Tuesday it was filing charges against Yingluck. She was summoned to hear the charges on Feb. 27. (Writing by Alex Richardson; Editing by Alan Raybould and Robert Birsel)