In July, as thousands of Thais demanded the resignation of the government in one of the largest street demonstrations since a 2014 military coup, Army Sergeant Ekkachai Wangkaphan sided with the protesters.
"Down with dictatorship," he wrote on Facebook under a news story about a jailed activist, a week before the protest. On the day of the protest, July 18, he shared a livestream and pictures with the hashtag of the Free Youth protest group. A few weeks later, he shared a photo of a protester carrying a placard saying "The country where you speak the truth and you go to jail."
His superiors in the Royal Thai Army warned him to stop. But he had already made up his mind to quit and left the army in October.
"When the protests escalated, orders to prohibit social media posts came in more often," Ekkachai, 33, told Reuters in an interview. "They want to nip it in the bud, but they can't."
Social media is exposing discontent among some soldiers, police and civil servants after months of protests against Prime Minister Prayuth Chan-ocha and the monarchy of King Maha Vajiralongkorn. Although Thai soldiers have occasionally expressed sympathy for protesters in past bouts of political unrest, the rapid expansion of social media is making it difficult to contain.
Reuters reviewed dozens of social media posts and messages on chat groups used by soldiers and police and found many expressing sympathy with protesters and anger or unease over the way those who oppose the government are being treated. Some posted about their loyalty to Thailand's institutions.
It is impossible to establish how far disaffection reaches based on social media activity. But the posts have attracted the attention of authorities.
"If you are posting things that are creating misunderstanding and provocation that would create instability, that is inappropriate," said Colonel Sirijan Ngathong, the army's deputy spokeswoman, adding that commanding officers were reviewing the social media activity of soldiers to prevent breaches of army rules.
She did not respond to requests for comment on the case involving Ekkachai or whether surveillance had increased since protests escalated in July.
Some posts appeared on the viral video-sharing app TikTok. One TikTok video, now removed, showed a soldier giving the three-fingered salute, a gesture of resistance featured in "The Hunger Games" film that Thailand's student-led, anti-government protest movement adopted. "Keep up the struggle, Thai brothers and sisters," said the caption.
The video's author told Reuters that he is a serving professional soldier but asked that his name not be used.
Some sections of the army have intensified their clampdown. A message posted by a coordinator in a private chat group used by officers in one artillery regiment, reviewed by Reuters, prohibited soldiers from joining protests or giving any political opinions on social media.
"After finding political expressions that were not suitable, commanders are asked to consider and rectify accordingly and to explain the political situation correctly to troops," the message said.
The army did not respond to a request for comment on the message.
It is unclear if disaffection will affect the protests or the way the government responds to them.
"While there is some disaffection within the armed forces, grumblings do not remain significant enough to constitute a significant faction," said Paul Chambers, a politics expert at Naresuan University in northern Thailand.
Government spokesman Anucha Burapachaisri declined to comment on disaffection among members of the security forces or civil service, saying only that the country should be focused on dialogue between those with different views.
Tens of thousands of people have protested in the streets of Thailand since July, calling for a new constitution and the removal of Prayuth, who led a military coup in 2014. Protesters have also demanded curbs on the powers of the king, until recently a taboo subject in a country where criticism of the monarchy is a crime.
The army plays a pivotal role in Thailand, which has been ruled by serving or former military officers for more than two-thirds of the time since the end of absolute monarchy in 1932. Thailand's army has seized power 13 times since then and has on several occasions been involved in bloody crackdowns on protesters including in 1973, 1976, 1992 and 2010.
Although many of the coups have had the broad support of the armed forces, cracks in the military have been exposed in the past. During a bloody 2010 crackdown on red-shirted anti-government protesters in Bangkok, some green-uniformed soldiers openly sympathized with the demonstrators, tipping off the group's leaders ahead of a planned army operation. They were dubbed "watermelons" - green on the outside with red sympathies on the inside.
That same year, rogue general Khattiya Sawasdipol – known as "Seh Daeng" or "Commander Red" - was assassinated after he came out in support of anti-government protesters, showing that displays of disloyalty in the Thai military can be dangerous.
"Security forces, especially those who have to confront the protesters, are in a stressful position," said Kiranee Tammapiban-udom of government consultancy Maverick Consulting Group. They have to follow orders but at the same time are branded "servants of tyranny" by protesters, she said.
One protest leader, Tattep Ruangprapaikitseree, said he encouraged security forces to disobey orders. "Turn your backs to your commanders, the regime will collapse," he told Reuters.
Another soldier who had also posted on social media said he was looking to defuse tension rather than escalate it. "Maybe it's time for the older generation to listen to the young," he said. "Asking Prayuth to quit and for changes to the constitution is not abolishing the monarchy."
Dress Code: Yellow
Some Thai police and civil servants are also questioning their roles. Many have been ordered to join official displays of loyalty to the crown, such as lining royal motorcade routes wearing yellow shirts - the king's colour.
Police Colonel Kissana Phathanacharoen told Reuters such activities are part of police duty and that law enforcement was politically neutral.
"Is this police work?" queried one police officer in an internal chat group, responding to a superior officer's request in the group for participants to join a royal event. The superior officer responded in the chat group that he was passing on orders and that questions should be addressed to more senior levels.
One document seen by Reuters, sent by the Bangkok Metropolitan Police to the Office of Police Strategy, a national body, requested "250 female police officers and 1,950 male along the route of the royal motorcade" for a funeral on October 29 in Bangkok.
"Dress code: yellow shirt with yellow collar. Long black pants, black shoes." Bangkok police spokesman Kissana said this was a normal police duty.
"Basically, we are disguised as civilians," a female police officer in her late 20s from the Royal Thai Police told Reuters, asking to remain anonymous. "We're told to wear yellow and shout 'Long live the king'." Protesters say police are easy to spot on such occasions because of their short haircuts.
One 23-year-old civil servant complained at being ordered to attend a seminar to praise the works of the Chakri dynasty, of which Vajiralongkorn is the 10th king.
"I can't do much, so I donate to the protesters," she told Reuters.