BANGKOK (AP) — A Thai court sentenced a university student to 2 1/2 years in prison on Tuesday for posting a message on Facebook that the court said insulted the country's king.

A Criminal Court judge found 24-year-old Akkaradet Eiamsuwan guilty of violating Thailand's lese majeste law, which punishes people who defame, insult or threaten the monarchy.

The ruling said Akkaradet used an alias to post the message on Facebook in March. He was arrested in Bangkok in June and has been in jail since then.

The court said it reduced an original sentence of five years' imprisonment to 2 1/2 years because the defendant had confessed to the offense.

Thailand's lese majeste law is the world's harshest, providing for jail terms of three to 15 years.

The role of the monarchy has come under closer scrutiny in recent years due to concerns about succession when 86-year-old King Bhumibol Adulyadej reaches the end of his reign. The political turmoil Thailand has suffered over the past eight years, with various political factions contending for power, is linked to such concerns.

Prime Minister Prayuth Chan-ocha — who led a military coup as army commander in May — is an ardent defender of the monarchy, having served for years in an infantry regiment known as the Queen's Guard. In September, he said his government "considers it a crucial duty to glorify this institute with loyalty and to protect their prerogatives." Prayuth vowed to use a variety of means to halt "those making impetuous, careless comments or with bad intentions undermine the nation's major institution."

Last month, a criminal complaint was brought against a prominent Thai intellectual over statements he made about the monarchy, including a comment that traditional stories about a king who died more than 400 years ago might not be true. Sulak Sivaraksa, 82, a self-described royalist, has been the target of several lese majeste complaints since the 1980s.

Other cases involving ordinary citizens have been vigorously prosecuted since the coup, usually before military courts with no opportunity for appeal. The charge of lese majeste has often been used as a weapon to harass political enemies, but the number of cases has skyrocketed in recent years.

The country's current leaders have allocated a large budget to the military to protect the king and instructed schools to stress patriotic themes in their curriculums.