An Australian writer has been sentenced to three years in prison for insulting Thailand's royal family in a novel he wrote.

Bangkok's Criminal Court handed Harry Nicolaides, 41, of Melbourne a six-year sentence, but the term was reduced because he entered a guilty plea, the judge said, according to the Associated Press.

The charges stem from a passage in Nicolaides's 2005 Verisimilitude, which only sold seven copies, that allegedly insulted King Bhumibol Adulyadej and the crown prince.

As he was escorted out of courtroom in handcuffs and shackles, Nicolaides said, "I would like to apologize."

He said he has "unqualified respect" for the king of Thailand and didn't mean to insult him.

The passage discusses the personal life of a fictional prince, and the presiding judge told the court it "suggested that there was abuse of royal power."

Under Thailand's lese majesty law, insults against the monarchy garner penalties of three to 15 years behind bars.

The 81-year-old King Bhumibol is the world's longest-serving monarch and is highly revered by Thais.

Nicolaides was arrested Aug. 31 at Bangkok's international airport before boarding a flight home. Human rights groups say he was unaware of an arrest warrant issued for him back in March. He was indicted in November and denied bail.

The Australian had lived in Thailand from 2003 to 2005 and taught in the northern city of Chiang Rai.

He described his novel as commentary on the political and social life of contemporary Thailand.

Nicolaides is not the first foreigner to be charged under Thailand's strict lese majesty law.

In 2007, a Swiss man was given a 10-year prison sentence for defacing pictures of King Bhumibol while apparently drunk. His case marked the first conviction of a foreigner for lese majesty in at least a decade.

Roland Jufer was later pardoned by the king after serving a month behind bars.

With files from the Associated Press