Image copyright Wyn Ellis Image caption Dr Ellis sent the BBC a picture of himself in detention at the airport

A UK academic has spent the last four days in detention at an airport in Thailand over a dispute arising from a UN report he wrote nine years ago.

Agricultural consultant Wyn Ellis was stopped at Bangkok Suvarnabhumi Airport and told he had been reported as a threat to national security.

It is a twist in an extraordinary saga which shows problems over protecting intellectual property in Thailand.

It also highlights the dangers of exposing well-connected Thai officials.

Dr Ellis, who has been working with the UN on sustainable rice production, was stopped at immigration at the airport.

Plagiarism row

In 2008, Dr Ellis, who is originally from Swansea, spotted a dissertation on promoting organic agricultural products, in particular asparagus, that seemed familiar.

On reading it, he realised a lot of it had been copied from a report on a year-long study he had conducted for Thailand's International Trade Centre two years earlier.

On further investigation he realised that nearly all of the dissertation had been copied from other sources; only in 14 pages out of 161, he says, could he not find clear evidence of plagiarism.

The dissertation had been submitted by Supachai Lorlowhakarn - director of Thailand's National Innovation Agency (NIA), an organisation that promises to promote and protect intellectual property - for his PhD at Thailand's elite Chulalongkorn University.

Dr Ellis filed a complaint, accusing Mr Supachai of stealing intellectual property, and asking the university to reject the dissertation.

Nothing happened, and Mr Supachai was allowed to graduate.

But a great deal happened to Dr Ellis.

Journalist charged

The NIA director filed nine lawsuits against him, including charges of criminal defamation, which carries a possible two-year prison sentence.

He received death threats, had rocks thrown through his car windows and found military personnel stalking his home.

An American journalist, Erika Fry, who wrote about his case for a Thai newspaper, had to flee the country in July 2010 after Mr Supachai filed a criminal defamation charge against her.

She says her paper failed to defend her.

The university did eventually begin an investigation into Mr Supachai, but only in 2010.

The Times Higher Education exposed the delay in the investigation in April 2012, and in June 2012 Mr Supachai was stripped of his doctorate.

Shortly afterwards he was convicted of criminal forgery of Dr Ellis' employment contract.

Despite all this, NIA continued to employ him up to the end of 2014.

Dr Ellis eventually won seven of the nine cases against him, settling the other two out of court, but the last case did not finish at the Supreme Court until May 2014.

Now he has discovered that Mr Supachai had asked the Immigration Department back in 2009 to blacklist him.

Despite a letter from the NIA retracting that request, Dr Ellis finds himself in a holding room at the airport, wondering when he will be freed.