Retired general Prayuth Chan-ocha, the man who led a military coup in Thailand five years ago, has been elected as the country's civilian prime minister.
The ex-junta leader had been serving as prime minister since the coup.
He was chosen by parliament on Wednesday, but the opposition said the vote was rigged as the Senate was largely hand-picked by the military.
The country's March election, the first since 2014, resulted in no party winning a clear majority.
The opposition Pheu Thai party, linked to ousted former PM Thaksin Shinawatra, won the most seats in the lower house but the upper house was appointed by the military government.
Hence the combined vote of both houses saw Mr Prayuth elected, despite his not having a majority in the lower house.
The military has been criticised for taking steps to ensure it would remain influential, including changing the constitution in 2017.
Thailand has been buffeted by political instability for years, largely a battle between supporters of the military and former Prime Minister Thaksin.