Canberra has blasted China’s “deeply regrettable” decision to bar its ambassador from a Beijing courthouse where an Australian writer was put on trial for spying, deepening a diplomatic freeze between the two countries.

Yang Hengjun, a former Chinese state employee turned pro-democracy blogger who is a naturalised Australian citizen, has been held in China for more than two years on espionage charges.

Court officials barred Australian diplomats from observing the trial that took place at the Beijing Number 2 Intermediate People’s Court on Thursday because they said the case involved national security.

“This is deeply regrettable, concerning and unsatisfactory,” Graham Fletcher, Australia’s Ambassador to China, said outside the courthouse, where diplomats and journalists were watched by dozens of police officers.

“We’ve had longstanding concerns about this case, including lack of transparency and, therefore, have concluded it’s a case of arbitrary detention,” he added.

Yang’s secretive trial echoes those of Michael Spavor and Michael Kovrig, two Canadian citizens who have been charged by Chinese authorities with spying. Their detention was in retaliation for the arrest of Meng Wanzhou, chief financial officer of Huawei, the Chinese technology group, in Vancouver following a US extradition request over allegations that she had violated sanctions against Iran.

Yang said in a letter to his family that was smuggled out of detention in March but released on the eve of the trial that his health had deteriorated during his 26-month confinement without access to fresh air or sunshine.

But he said he was spiritually strong and would face suffering and torture with resilience and dignity.

“If the worst comes to the worst, if someone wants to take revenge on me for my writings, please explain to the people inside China what I did, and the significance of my writing to people in China,” he wrote.

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

Yang’s trial is being heard as Australia-China relations have sunk to their lowest level in a generation. Ties have frayed in the wake of Canberra’s call for an international probe into the origins of Covid-19 and its introduction of tough laws against foreign interference.

Beijing has slapped tariffs and other restrictions on a range of Australian goods in what analysts maintain is a campaign of “economic coercion”.

Chinese authorities have also detained Cheng Lei, an Australian journalist who worked for China Global Television Network, the state-controlled broadcaster, last year. She was charged with illegally supplying state secrets overseas in February.

Marise Payne, Australia’s foreign minister, criticised Chinese authorities’ handling of Yang’s case.

“I very much hope Dr Yang is provided with a fair trial but we have not seen any explanation or evidence of the charges brought against him,” she told Australian radio.

“We are not interfering in China’s legal system. The concerns we’ve raised are legitimate ones.”

Payne said Australian diplomats had raised concerns with authorities over Yang’s “delayed and limited” access to legal representation. Australia expects “basic international standards of justice to be met”, she added.