* Army chief says takeover needed to restore order
* Had urged rivals to agree compromise solution
* Military suspends constitution and announces night-time curfew
* Rival protest camps ordered to disperse
* Market analysts expect sell-off, but say may not be severe (Adds analyst comment, reaction)
By Amy Sawitta Lefevre
BANGKOK, May 22 (Reuters) - Thailand's army chief General Prayuth Chan-ocha seized control of the government in a coup on Thursday, two days after he declared martial law, saying the military had to restore order and push through reforms after six months of turmoil.
The military declared a 10 p.m. until 5 a.m. curfew, suspended the constitution and told outgoing cabinet ministers to report to an army base in the north of the capital by the end of the day. Rival protest camps were ordered to disperse.
Thailand is locked in a protracted power struggle between supporters of ousted former premier Thaksin Shinawatra and opponents backed by the royalist establishment that has polarised the country and battered its economy.
"In order for the situation to return to normal quickly and for society to love and be at peace again ... and to reform the political, economic and social structure, the military needs to take control of power," Prayuth said in the televised address.
The general made his broadcast after a meeting to which he had summoned the rival factions in Thailand's drawn-out political conflict, with the aim of finding a compromise to end six months of anti-government protests.
But no progress was made and Prayuth wound up the gathering by announcing he was seizing power, according to a participant.
The Thai armed forces have a long history of intervening in politics - there have been 18 previous successful or attempted coups since the country became a constitutional monarchy in 1932, most recently when Thaksin was deposed in 2006.
Hundreds of soldiers surrounded the meeting at Bangkok's Army Club shortly before the coup announcement and troops took away Suthep Thaugsuban, leader of the protests against the pro-Thaksin government.
Some of the other meeting participants were being held back in the venue afterwards, said a Reuters reporter waiting outside.
SHOTS FIRED INTO AIR
The army ordered rival protest camps to break up and soldiers fired into the air to disperse thousands of pro-government "red shirt" activists gathered in Bangkok's western outskirts, a spokesman for the group said.
The military detained at least one leader of the activists, said the spokesman, Thanawut Wichaidit.
A Reuters witness later said the protesters were leaving peacefully. Earlier their leader, Jatuporn Prompan, said they would continue their rally despite the coup.
The army had declared martial law on Tuesday, saying the move was necessary to prevent violence.
Twenty-eight people have been killed and 700 injured since the anti-government protests erupted late last year.
"Martial law may have been to test the waters, the army gave the opposing camps a chance to negotiate a way out but I think the endgame was always the military taking over," said Kan Yuanyong of the Siam Intelligence Unit think-tank.
"The possibility of conflict is now much higher," he said. "Thaksin will fight back."
Former telecommunications tycoon Thaksin has lived in self-exile since 2008 to avoid a jail term for graft, but still commands the loyalty of legions of rural and urban poor and exerts a huge influence over politics, most recently through a government run by his sister, Yingluck Shinawatra.
He was not available for comment but a pro-Thaksin activist in his hometown of Chiang Mai said there was no immediate plan to protest.
"As of now we will not head to Bangkok, no plans. We will follow today's situation closely first," said Mahawon Kawang, a red shirt leader in Chiang Mai.
"EVERYONE WON'T BACK DOWN"
In a first round of talks on Wednesday, Prayuth had called on the two sides to agree on a compromise that would have hinged around the appointment of an interim prime minister, political reforms and the timing of an election.
But neither side backed down from their entrenched positions on Wednesday and again on Thursday, participants said.
"As we cannot find a way to bring the country to peace and everyone won't back down I would like to announce that I will take power. Everyone must sit still," Prayuth told the meeting, according to one participant who declined to be identified.
The army has also clamped down on the media, including partisan television channels, and warned people not to spread inflammatory material on social media.
Leaders of the ruling Puea Thai Party and the opposition Democrat Party, the Senate leader and the five-member Election Commission had joined the second round of talks on Thursday.
Acting Prime Minister Niwatthamrong Boonsongphaisan, who did not attend, told reporters before the talks that his government could not resign as its enemies were demanding as that would contravene the constitution.
"The government wants the problem solved in a democratic way which includes a government that comes from elections," he said.
Yingluck was forced to step down as premier by a court two weeks ago, but her caretaker government, buffeted by six months of protests against it, had remained nominally in power.
Government officials were not available for comment after the coup announcement.
Thailand's gross domestic product contracted 2.1 percent in January-March from the previous three months, largely because of the unrest, adding to fears it is stumbling into recession.
But weary investors have generally taken Thailand's frequent political upheavals in their stride, and analysts said the impact on markets in Southeast Asia's second largest economy might not be too severe.
"It's back to the old days," said Christopher Wong, senior investment manager at Aberdeen Asset Management Asia in Singapore. "Probably with the military coming in there's a bit more stability. There may be a knee-jerk reaction ... but as the dust settles it is probably back to normal."
Thailand's SET index closed before the coup announcement, ending 0.2 percent higher. The index is up 8 percent this year. The baht weakened to 32.54 to the dollar after the coup announcement, from 32.38 earlier.
The anti-government protesters want to rid the country of the influence of Thaksin, who they say is a corrupt crony capitalist who commandeered a fragile democracy and used taxpayers' money to buy votes with populist giveaways.
They wanted a "neutral" interim prime minister to oversee electoral reforms before any new vote.
The government and its supporters said a general election that it would likely win was the best way forward and it had proposed polls on Aug. 3, to be followed by reforms. (Additional reporting by Juarawee Kittisilpa; Writing by Robert Birsel; Editing by Alan Raybould and Alex Richardson)