A Stockholm court on Friday cleared Sweden's former ambassador to Beijing of charges of overstepping her mandate by trying to negotiate the release of a Chinese dissident.

Anna Lindstedt, who was envoy to Beijing between 2016 and 2019, was accused of brokering and attending an unauthorised meeting in January last year to get a Chinese-Swedish publisher freed from custody in China.

The case of dissident Gui Minhai -- a five-year-saga beginning when he vanished while on holiday in Thailand -- has strained ties between Sweden and China.

The meeting was between the publisher's daughter Angela Gui and two businessmen with alleged ties to Beijing.

Angela Gui wrote on her blog a few weeks after the meeting that the businessmen claimed they could help to get her father released if she stopped talking to the media.

She later described the tone of the meeting as "threatening".

A day after the blog post, the Swedish intelligence service confirmed it had opened an investigation into the meeting.

Lindstedt faced a charge of "arbitrariness during negotiations with a foreign power" which carries a maximum jail term of two years, although the prosecutor had only asked for a suspended sentence.

It was the first time since the 18th century that an ambassador has faced trial in Sweden.

The court said for someone to be convicted of the crime they would have had to falsely pose as a representative of Sweden and engage in actual negotiations with a representative of a foreign power.

Judge Anna Flodin said the court did not believe it had been proven that Lindstedt entered into any negotiation with someone representing the Chinese state.

"The court also found that if she had, she would have been within her right as Sweden's ambassador to China," Flodin told a press conference.

Anna Lindstedt, Beijing envoy between 2016 and 2019, is accused of brokering an unauthorised meeting to get a Chinese-Swedish publisher released
Anna Lindstedt, Beijing envoy between 2016 and 2019, is accused of brokering an unauthorised meeting to get a Chinese-Swedish publisher released AFP / Jonathan NACKSTRAND

During the trial, Lindstedt denied the charges and described the experience as "Kafkaesque."

"As a Swedish diplomat you have to be able to turn every stone when trying to get a detained person released," she told news agency TT following the verdict.

"I have always acted in Sweden's best interest," she said, adding that the verdict was not only important for her but also for "diplomacy".

Gui Minhai, known for publishing gossipy titles about Chinese political leaders in Hong Kong, disappeared while on holiday in 2015 and resurfaced in China, where he served two years in prison.

A few months after his October 2017 release he was again arrested, this time while on a train to Beijing with Swedish diplomats.

He was hit with a 10-year jail term earlier this year on charges of illegally providing intelligence abroad.

China insists the matter is an internal affair and has been stung by criticism from Sweden.

The Swedish foreign ministry removed Lindstedt from her post but she has stayed on at the ministry without an assignment.

The ministry has maintained it had no prior knowledge of the meeting, saying Lindstedt acted on her own initiative.

Ministry representatives told the court that Lindstedt had been instructed to handle Gui Minhai's case through Stockholm.

In turn, Lindstedt maintained she had not received those instructions and that she had told her superiors of the meeting, according to public broadcaster SVT.

Fellow diplomats had rallied to Lindstedt's defence, arguing that she had acted well within her remit.

"I don't think that the ambassador has committed a crime, absolutely not," former envoy Sven Hirdman told AFP on the first day of the trial.

"She tried to do what she should do as a Swedish ambassador -- to solve a complicated consular case between Sweden and China."