WHAT had begun as the imposition of martial law on May 20th grew into a full-blown coup by the army as The Economist went to press. On television the army commander, General Prayuth Chan-ocha, announced that the armed forces would restore order and enact political reforms—though quite what that means is unclear.

Even before his statement, the army had shut down a dozen television stations and thousands of community radio stations, and it ordered the rest of the media to suspend critical thinking—banning journalists, for instance, from interviewing anyone not holding an official position. At that point General Prayuth had indicated that the last thing on his mind was a coup. On Bangkok’s streets the troop presence was light. The commander called a meeting for May 21st of all sides of the stand-off that has paralysed Thai politics for months. They nearly all turned up at the Army Club: senior members of the ruling Pheu Thai party; the head of their grassroots movement, the red shirts; the opposition (but establishment) Democrats; and Suthep Thaugsuban, the establishment-backed leader of the street protests that since November have attempted to topple the government.

The aim seemed to be to find a path to electoral democracy. They met again at the club the following day. But, though troops sealed off the premises to concentrate minds, it appears that a political deal to the impasse was no nearer. At that point, the army detained the faction leaders. Of course, the notable absentee was Thaksin Shinawatra. In self-imposed exile in Dubai, he is the founder of Pheu Thai and the other parties that have won all the elections since 2001 when they have been allowed to take place. It is Mr Thaksin’s influence that the establishment wants to expunge from politics.

The coup will have swift ramifications. Thailand risks financial markets taking fright, cutting it off from international capital. It also guarantees more violence. The red shirts have long threatened to rise up against a coup. The idea of an appointed government—Mr Suthep’s plan that the army might conceivably back—will also meet red-shirt resistance. As it is, since November, 28 people have died in the conflict and hundreds have been injured.

The army will probably now clear the rally sites of both anti- and pro-government protesters. But Mr Suthep, the street-level embodiment of the civil service, the army, the judiciary and the court surrounding the frail King Bhumibol Adulyadej, had declared to his supporters that the fight to eradicate Mr Thaksin and his family from the body politic was still on.

The cost of the country’s political crisis and lack of economic direction is fast becoming clear. On the eve of the coup, the state planning agency said that the Thai economy had tipped into recession. Only a decade ago Thailand was often held up as a South-East Asian showcase combining growth and democracy.

What happens next is hard to predict. Just possibly the coup could end with a political settlement in which normal democratic politics resumes. More probably, it will lead to a framework allowing the historical elites to continue in charge of the country. Either way, it will not be up to General Prayuth. In Thailand the real decisions are made in the privy council and at the royal palace.

Charting a path out of economic stagnation, social failure and now yet another coup is greatly complicated by the imminent end of an era, the 64-year reign of King Bhumibol. He is revered and popular, unlike his son, Prince Maha Vajiralongkorn. The 61-year-old crown prince appears to be eccentric. A curious video once did the rounds showing the prince with his third wife, in a state of undress, at a party for Foo Foo, his poodle. The dog carried the rank of air chief marshal. Now that the king’s reign is in its twilight, questions over the royal succession are factors in the polarisation of Thai politics. It threatens to divide society, the army and the palace.

The twilight is rendered silent by draconian lèse-majesté laws. But the army, the force defending the throne, has recently had unpalatable news. In late November the king signed a decree mandating that all decisions by the powerful defence council were subject to veto by the crown prince. The council includes the service heads and the permanent defence secretary. The heir apparent is now, in effect, their boss.

This will make it even harder for anyone thinking of subverting the royal succession. Mr Suthep’s sponsors, like many Thais, have long prayed for a miracle that gives the throne to the crown prince’s sister, Princess Sirindhorn. Involved with royal charity, she enjoys a saintly image. Some troops on the streets this week wore a purple ribbon, the princess’s colour.

Another royal decree, on April 4th, spelled out greatly expanded powers for Prince Vajiralongkorn’s own special army: the Royal Guard 904 Corps, or Ratchawallop, an infantry regiment under the prince’s command since 1978. The corps will now protect anyone the prince chooses and engage in any mission he feels necessary to protect national security. Commanding your own army carries risks. King Vajiravudh (Rama VI) formed the Wild Tiger Corps on his accession to the throne in 1910. Two years later resentful army officers attempted a coup.

The prince’s troops are better paid than regular soldiers. Increasingly, they are recruited in Thailand’s rural north and north-east—heartland of the Shinawatra clan. That may be no coincidence. To rule, the crown prince may feel he needs to tap into Mr Thaksin’s popular legitimacy. Likewise, to become prime minister again Mr Thaksin may need the crown prince. He is thought in the past to have paid off the prince’s gambling debts.

Whether the crown prince and Mr Thaksin are working in concert is unclear. Earlier this year, when the army was slow to provide protection for Yingluck Shinawatra, Mr Thaksin’s sister and prime minister at the time, the crown prince sent her soldiers. The courts remain part of the old establishment and have since kicked Ms Yingluck out of office. The elite may reckon that clawing back power from an elected government it dislikes—which this coup is clearly intended to do—may be easier now than after the king’s death. The risks to Thailand only mount.