Australia’s ambassador to China has labelled the treatment of Yang Hengjun “arbitrary detention” on the morning of the writer’s closed-door trial for espionage charges.

The envoy, Graham Fletcher, was on Thursday denied entry to the Beijing court where Yang will be tried after spending more than two years in jail.

“The reason given was because of the pandemic situation but the foreign minister has also told us it’s because it’s a national security case,” Fletcher said outside court.

“This is deeply regrettable and concerning and unsatisfactory. We’ve had longstanding concerns about this case, including the lack of transparency, and therefore have concluded it is an instance of arbitrary detention.”

On Thursday afternoon China’s foreign ministry spokesman, Zhao Lijian, said that cases of national security are not open to the public, and accused Australia of “gross interference” in China’s handling of the case, with Fletcher’s comments and the request to attend the trial. Zhao said China had made “stern representations” to Australia.

He said the case was held in accordance with the law, and would announce a verdict at a later date.

Yang – an Australian academic, author of spy novels, democracy activist and former employee of China’s state security ministry – has been detained since January 2019. He was arrested immediately on arrival at Guangzhou airport while travelling with his wife and son. He was formally charged with conducting espionage on behalf of a foreign country but Chinese authorities have not identified the country. Australia’s prime minister, Scott Morrison, has said it is “absolutely untrue” to say Yang had acted as a spy for Australia.

The detainee was initially held in “residential surveillance at a designated location” – a secretive form of detention denying access to lawyers and family, which has been classified by UN human rights experts as a type of enforced disappearance – before being moved to a Beijing detention facility. Over the past two years Yang reported being interrogated more than 300 times by dozens of different people, for hours at a time. He has maintained his innocence of all charges.

In a letter released on Wednesday, Yang accused the Chinese government of taking revenge on him for his writing, but said he was unafraid of the “suffering and torture” of a long prison sentence.

“There is nothing more liberating than having one’s worst fears realised,” he said. “I have no fear now. I will never compromise.”

China’s notoriously opaque justice system is even more so when it comes to national security cases involving foreigners. Fletcher said the only information the Australian government had received about the case was that Yang’s charges related to espionage. He was critical of the refusal to allow him or others access to the courtroom.

“It’s a treaty obligation [to allow consular access] and it’s also necessary to give, not only our government but other governments, confidence in the process.”

. The court system routinely reports conviction rates of about 99%, and Yang’s charges carry lengthy terms.

“Regardless of what happens today we will continue to advocate strongly for Dr Yang and his interests and rights, and continue to offer consular support to him and his family,” Fletcher said.

Australia’s foreign affairs minister, Marise Payne, said Yang had “delayed and limited” access to a lawyer, who had last visited him on 21 May.

“I very much hope that we have a transparent and open process,” Payne told ABC radio on Thursday. “We’re not interfering in China’s legal system. The concerns that we have raised are legitimate ones. But we do expect those basic international standards of justice to be met.”

Last week Payne criticised China’s refusal to give Australia information about the case in a statement the Chinese foreign ministry labelled “deplorable”.

Yang’s trial was due to start in January but was delayed for several months until an announcement last week that it was scheduled for Thursday.

His case is one of several prosecutions of foreigners from countries now in dispute with Beijing. Another Australian, the journalist Cheng Lei, has been detained for more than eight months on similarly vague national security charges. On Thursday Fletcher said there was no reason to link Yang’s case to the relationship between China and Australia.

Human Rights Watch’s Australia researcher, Sophie McNeill, said Yang had been denied the right to a fair trial “from the moment he was detained over two years ago”.

“He’s been ill-treated, shackled, denied contact with his family, blocked from accessing his lawyer – and now Chinese authorities are indicating Australian diplomats cannot attend the trial. This case is an indictment of Beijing’s nakedly politicised legal system, but it’s Yang who’ll pay the price.”