After months behind bars, one of China's most prominent human rights lawyers left a detention center Tuesday after receiving a suspended prison sentence in a case involving online comments critical of the ruling Communist Party.

The court convicted Pu Zhiqiang on charges of disturbing public order and inciting ethnic hatred, and sentenced him to three years in prison but said the sentence will be suspended for three years.

Six hours after the hearing, Pu was driven out of Beijing No. 1 Detention Center in the company of his wife and police officers.

From the car, Pu said he was "safe and sound" in a text message sent to The Associated Press.

His wife, Meng Qun, wrote: "He's well and still under residential surveillance. His health needs to recover, he needs some calm and adjusting time."

Lawyer Shang Baojun said the verdict wouldn't take effect for 10 days, during which Pu can appeal, and he can be kept in detention or under residential surveillance, which may be at a place which isn't his home.

The guilty verdict disqualifies Pu from practicing law, and he must comply with certain restrictions and not commit crimes during the three-year period or risk being jailed.

Since coming to power in 2013, Chinese President Xi Jinping has spearheaded crackdowns on civil activists, rights lawyers and online freedom of expression, in moves aimed at snuffing out any potential threats to the Communist Party's grip on power.

Pu was detained shortly after attending a May 2014 meeting to discuss commemorating 25 years since the Tiananmen Square massacre. Hundreds, possibly thousands, of protesters were killed in the crackdown, and the topic remains taboo in China.

After a prolonged investigation, Pu stood trial on Dec. 14 -- after more than 19 months in detention -- for several online comments that questioned Beijing's ethnic policies and poked fun at some political figures.

Pu's supporters believe the case was politically driven to punish the outspoken lawyer, who has become a leading figure among China's human rights lawyers.

Pu was active in defending free speech and represented artist Ai Weiwei in a tax evasion case that Ai's supporters said was politically motivated. He also was instrumental in pushing for the eventual abolishment of China's labor camp system, which allowed police to lock up people for up to four years without a trial.

Human rights group Amnesty International welcomed the suspended sentence but condemned the guilty verdict.

"Clearly it is positive that Pu Zhiqiang is unlikely to spend another night in jail, yet that cannot hide the gross injustice against him," William Nee, China researcher for the group, said in a statement. "He is no criminal and this guilty verdict effectively shackles one of China's bravest champions of human rights from practicing law."

The verdict also stirred mixed feelings from Pu's supporters, who celebrated his release but also said it was an injustice to find him guilty.

"After all, an innocent man has been locked up for 19 months. Under the suspended sentence, he finally can get out," said supporter Ren Jianyu. "It's good news but with a feeling of helplessness."

In one of his online comments, Pu urged Beijing not to treat the ethnic region of Xinjiang as a colony and act as a conqueror and looter.

In another, Pu questioned why there were bloody incidents involving the Muslim minority of Uighurs when Beijing keeps touting how great its ethnic policies are.

He also derided a veteran delegate to the national congress known for her six decades of never casting a dissenting vote. Pu said she was either truly dumb or played dumb.

"How can you convict someone because of words?" Pu supporter Guan Jing said near the court. "Which words are wrong, or which are the ones that we can use and the ones that we cannot? Is there a legal basis to regulate what a person can say or not say?"

The official Xinhua News Agency said the court believed Pu's comments on ethnic issues were provocative, effectively fanning ethnic hatred, and that his remarks on public figures were so vulgar and malicious they disturbed the public order.

Xinhua said Pu admitted to the actions and repented in court, but his lawyers said Pu only apologized for being impolite and insisted that he broke no law.

On Tuesday, hundreds of police barred foreign journalists from approaching the court. About a dozen diplomats who attempted to watch the verdict said they were turned away on the ground the courtroom was full.

At least one supporter who rallied outside the court was hauled away by police.