BEIJING — Canada has deported a veteran Chinese dissident, Yang Wei, on the grounds that he is a danger to the public.

Despite written testimony stating that Mr. Yang, 49, had mental health problems and faced certain prison time if sent back to China, a court issued a final ruling on Monday that Mr. Yang should be put on a plane departing Toronto on Wednesday afternoon, and arriving in Beijing on Thursday.

In making its ruling, the court relied on a document, reviewed by The New York Times, that mainly evaluated whether Mr. Yang would receive adequate care in China and brushed off concerns about his work as a dissident, saying there was no proof he would face incarceration if he returned.

Adam Wawrzkiewicz, a lawyer who was involved in an 11th-hour attempt to prevent Mr. Yang’s deportation, said that the government had justified the deportation on the grounds that Mr. Yang had been deemed a threat to public safety. Under Canadian law, that can override concerns that the forcible return of a refugee or asylum seeker could lead to his or her persecution.