Thailand's Constitutional Court has thrown out a legal challenge to Prime Minister Prayuth Chan-ocha's term limits, ruling he can stay in office.
It had suspended him while it heard the case but it had been widely expected to reject the opposition parties' petition.
The opposition argued General Prayuth had exceeded his constitutionally-limited eight years in office.
The former military chief seized power in a 2014 coup.
He made himself PM in August that year, meaning he has been the PM now for longer than that.
The Constitutional Court has a long history of ruling in favour of conservative, royalist groups and against those associated with reform; in the past 16 years it has sacked three prime ministers and dissolved three political parties, all from one side of Thailand's divided politics.
Few believed its judges, some appointed under Gen Prayuth, would be prepared to go as far as sacking him too.
The opposition case appeared to be strong. The new constitution, drafted in 2017 under Gen Prayuth's then-military government, stated that "The Prime Minister shall not hold office for a total period of more than eight years".
However the Constitutional Court argues that this only came into effect with the new constitution in April 2017, and that it is from this date that Gen Prayuth's years in office should be counted.
But this is not the verdict Gen Prayuth's supporters had been hoping for. They have been proposing June 2019 as the start date, when he was re-appointed prime minister following the first post-coup parliamentary election earlier that year.
This is important because Gen Prayuth has made it clear he would like to contest the next election, expected early in 2023, aiming to become Thailand's longest-serving prime minister - not bad for an army commander who said he was only taking power temporarily.
The Constitutional Court ruling means he has just two-and-a-half years left until he hits the term limit, making him less appealing as a prime ministerial candidate to conservative parties.
There have been rumours of powerful lobbying behind the scenes to sway the court's decision.
The fact that the Constitutional Court suspended Gen Prayuth from his job while they reached their decision - widely seen here as a humiliation - and that he did not get his preferred outcome, suggests there are splits in the broad conservative coalition which chose him as leader in 2019.
He is much less popular now, after eight years in which the Thai economy has not performed well, although there is no obvious rival as the figurehead for conservative, royalist values.
What all this manoeuvring underlines is how fluid and unsettled Thai politics still is, more than eight years after a coup whose leaders said they were going to sort out the country's political arrangements once and for all.
The eight-year term limit was inserted into the constitution to prevent popular politicians from leveraging election victories into a long-term hold on power, as exiled former prime minister Thaksin Shinawatra was accused of doing.
Yet no-one seems to have anticipated that the limit would come back to haunt the man who supervised the writing of that charter.
The political rules in Thailand are still being disputed, and no-one in a country which has experienced at least 20 military coups would bet on there never being another.
Johnathon Head not holding back on this article, better than the Party Tripe reported in the Junta Propoganda Bangkok Post.