Judge Khanakorn Pianchana, who caused a sensation last year by alleging interference in judicial rulings, died after shooting himself at his house in Chiang Mai on Saturday.

A senior judge who shot himself in a Yala courtroom last October in a protest against alleged interference in judicial rulings died of a self-inflicted gunshot wound on Saturday morning.

Khanakorn Pianchana, 50, who previously served as a senior judge at the Yala provincial court, shot himself in the heart in his house in Doi Saket district in Chiang Mai on Saturday morning while his wife and their daughter were out.

When his wife returned, she found him badly wounded. An ambulance was called to send him to Doi Saket Hospital before he was later transferred to McCormick Hospital Chiang Mai

Doctors tried in vain to save his life and the judge died at 10.45am, according to Sarawut Benjakul, secretary-general of the Office of the Judiciary.

His body will be sent to Maharaj Nakorn Chiang Mai Hospital for a post-mortem examination.

Before the shooting, Mr Khanakorn posted a two-page farewell letter on his Facebook page. The letter, dated March 6, mentioned the incident on Oct 4 last year when he had shot himself in the Yala courtroom after reading a ruling. He cited as the reason for the second attempt the unbearable consequences of his action — the prospects of losing the job he loved and being convicted in a criminal case.

"I was later investigated and charged and became a suspect in a criminal case. I do believe that I will be dismissed from government service. Legal proceedings against me have also just started. Being deprived of a job I love means a loss of one's true self,'' he wrote.

He insisted his act in October was motivated by a sincere desire to return justice to the people. "I do not regret it and I'm proud of being part of administering justice for the Thai people," read the letter.

The judge also mentioned what he viewed as a structural problem with the judicial system.

"In the past, we had the 1997 constitution written by the CDC. People and academics admit it was the most democractic charter the country had ever had," he wrote, referring to the constitution written by the 99-member Constitution Drafting Council set up in 1996 and comprising 76 indirectly elected members and 23 academics.

"You may wonder why, when the charter was in effect, reviewing a ruling at the first-court level was not allowed. Why is that? Could it be that the drafters knew such a review could pave the way for interference in a ruling by regional court presidents?

"Let me ask my friends and fellow countrymen: Do you find an evil intention in what I had done, which led to disciplinary and criminal action against me? A reply in your heart is enough. As for me, I knew from the start. It's a pity you are not my judge."

On Oct 4, the judge shot himself in a Yala courtroom after reading a ruling on a case involving a violent incident in the Deep South.

Mr Khanakorn posted a 25-page statement on Facebook on the same day. He explained that he had acquitted five suspects against the advice of more senior judges who had reviewed the case and in full knowledge of the consequences to his career.

The statement included the messages "Return the ruling to the judges" and "Return justice to the people", sparking a controversy about the country's judicial system.

Three days later, the Judicial Commission set up a three-member panel, one from each tier of courts, to investigate his case. After the findings, the Judicial Commission in November voted to set up another panel to consider disciplinary action against him and to transfer him to a temporary position in his hometown Chiang Mai.

The commission also appointed a subcommittee to study and improve the criteria, guidelines and methods of checking draft rulings and to find measures preventing a repeat of such an incident.

Mr Khanakorn also gave a bank account number and asked for donations from the public for his daughter's scholarship.

Judge Khanakorn Pianchana posted a letter on his Facebook page on Saturday before shooting himself at his house in Chiang Mai. He wrote about the consequences of his fisrt suicide bid in court last year.