BANGKOK -- Thailand's endless political crisis has taken a familiar turn, with the military asserting control after failing to strike a bargain with divisive ex-Prime Minister Thaksin Shinawatra.

The breakdown of secret talks between the army chief and Thaksin, who lives in exile overseas to avoid prosecution, appears to have triggered the coup.

In a surprise move, soldiers detained a number of political figures Thursday in the midst of mediation talks. What began Tuesday with a declaration of martial law, which the military denied was a coup, has quickly become one.

On Wednesday, the military called together representatives from the government, ruling and opposition parties, pro- and anti-Thaksin groups, the senate and the election commission, ostensibly to seek a compromise. Another round of talks was held Thursday.

The Thaksin camp is eager to move ahead with national elections it believes will keep it in power. Its opponents want a provisional prime minister to govern before the vote. With the two sides continuing to talk past each other, the military, ostensibly playing the role of mediator, took the situation into its own hands. The final straw may have been a failed parley between General Prayuth Chan-ocha, the army chief, and Thaksin himself.

The general contacted the former prime minister on Wednesday through the Thaksnite ruling Pheu Thai Party. Prayuth proposed a compromise whereby the cabinet would resign and transfer power to a provisional government. In return, the anti-government protests that have gone on for months would disband. After Thaksin refused, the general phoned Thaksin's sister, Yingluck Shinawatra -- herself removed from the prime minister's seat earlier this month by the Constitutional Court -- to ask her to persuade Thaksin.

That evening, as Prayuth sat in on the mediation talks, he received Thaksin's answer: The Shinawatra clan would step back from politics for now, but only if Thaksin and Yingluck were spared further prosecution and granted amnesty. A furious Prayuth asked the caretaker justice minister one last time whether he and the rest of the cabinet would resign. When he said no, the military forced them out.

It named Kittipong Kittayarak, a former permanent secretary of the justice ministry, to head a provisional government. The military appears to want a new constitution, followed by elections and the reinstatement of civilian rule. The same thing happened after the 2006 coup that ousted Thaksin. But that only deepened the gulf between the former prime minister's allies and enemies.

Although it presents itself as a neutral broker, the military forms the vanguard of the anti-Thaksin establishment, which also includes monarchists, bureaucrats and business leaders. Kittipong, its choice for provisional prime minister, has close ties to the protest movement that sought to topple Yingluck's government. That is hardly the makings of an impartial leader.

When Thais go to the polls, the Thaksin camp holds an unshakable advantage among the country's rural majority, as well as poor and middle-income city dwellers. That is why its opponents are trying any means they can to weaken it, including changes to the constitution and electoral system.

Thaksin's supporters are unlikely to acquiesce to a military-led political overhaul. Some close to the ex-prime minister want to form a government-in-exile, military sources said. International condemnation of the coup may work to his advantage.

Word of the coup threw the pro-Thaskin United Front for Democracy Against Dictatorship into disarray, media reports said. The so-called red-shirts had been holding a long-running mass rally in support of Yingluck's government on the western outskirts of the capital.

Back in 2010, UDD members occupied central Bangkok. Heavily armed hardliners in the group clashed with security forces, leaving more than 90 people dead. The army's own ranks are said to include many "watermelon" soldiers, so called because they harbor loyalty to the red shirts under their camouflage. There is also a Thaksinite faction in the police force, where the former prime minister got his start. Such groups could unite with the red shirts in a pushback against military rule.