Thailand's Constitutional Court on Friday ruled Prime Minister Prayuth Chan-ocha had not exceeded the maximum eight years allowed in office, clearing the way for his return from a five-week suspension.
The ruling will be a big boost for Prayuth, a staunch royalist whose premiership has been beset by attempts to unseat him, including four house censure motions, a conflict of interest case and protests challenging his leadership and the monarchy.
"The accused ... has been in the prime minister position not exceeding the limit stipulated by the constitution," a judge said in a 25-minute televised reading of the verdict.
"Therefore he is not disqualified."
Prayuth ruled as head of a military council after he overthrew an elected government when he was army chief in 2014.
He was junta leader and prime minister until an election in 2019, held under a military-drafted constitution in which an eight-year limit for a prime minister was set, after which a new parliament chose him to stay on as premier.
Deciding a case filed by the opposition Pheu Thai party, the court said a majority of judges had concluded Prayuth's tenure started in 2017, meaning he could serve until 2025, if re-elected.
Pheu Thai, whose government was toppled in the 2014 coup, had maintained he had reached the eight-year mark last month and asked the court to set the record straight on whether his time as premier in a junta should be included.
The judges ruled 6-3 in Prayuth's favour.
Prayuth, 68, had been suspended from office while the court deliberated the case.
"The prime minister respects the court decision and wants to thanks all that have given him encouragement," said government spokesperson Anucha Buraphashaisri.
"(He) will continue to try and use full capacity ... to transform Thailand and lead the country towards a golden age of prosperity for all Thai people."
The Pheu Thai party, founded by loyalists of former prime minister and telecoms tycoon Thaksin Shinawatra, who was himself ousted in a 2006 coup, could not immediately be reached for comment on the verdict.
Prayuth is among the longest-serving premiers in Thailand, a country that has seen more than 10 coups in the past century and had numerous leaders from the military.
An opinion poll in early August showed Prayuth's popularity waning, with nearly two-thirds of people surveyed wanting him to leave office, while a third preferred to wait for the court ruling.
An election must take place by May 7 next year at the latest, according to the election commission. Prayuth has yet to say if he intends to contest it.
(Reporting by Panu Wongcha-um and Panarat Thepgumpanat; Writing by Martin Petty; Editing by Robert Birsel)