BEIJING — A Chinese court sentenced a prominent legal activist to four years in prison Sunday in a case widely seen as a demonstration of the Communist Party leadership’s determination to quell any challenges to its hold on power.

The activist, Xu Zhiyong, was convicted of “gathering a crowd to disturb public order,” a charge that stemmed from his role organizing a grass-roots New Citizens Movement, which sought to give voice to public discontent over official corruption and social injustice.

After a judge of the No. 1 Intermediate People’s Court in Beijing announced the guilty verdict and sentence, Mr. Xu denounced the trial as he was led away by guards, said one of Mr. Xu’s lawyers, Zhang Qingfang.

“He said, ‘The court today has completely destroyed what remained of respect for rule of law in China,’ and then he was taken away,” said Mr. Zhang. His account of the verdict and Mr. Xu’s comment was confirmed by the other defense lawyer, Yang Jinzhu.

“He can still appeal, but this outcome was decided by the senior leaders, and there’s no hope of changing the verdict,” Mr. Zhang said. He said the court could have imposed a maximum sentence of five years.

The judgment, coming unusually swiftly after a trial Wednesday, will silence Mr. Xu for now. But the sentence could also enhance Mr. Xu’s prominence as an advocate for political liberalization. Mr. Xu and his two lawyers remained silent in protest for most of the proceedings, but Mr. Xu used his concluding statement to deliver part of an impassioned manifesto for democratic change, free speech and rule of law. The full text has circulated on the Internet.

For the verdict hearing, the police stood guard for blocks around the courthouse, keeping away journalists, diplomats and ordinary citizens concerned about the case. Journalists who tried to approach the court were told to leave.

As the first prosecution of a high-profile activist under Xi Jinping, the Communist Party secretary who took power in November 2012, the case was seen as a barometer of how China’s new leadership — the first in a decade — would respond to organized calls for reform. Some liberal intellectuals and rights advocates initially hoped that Mr. Xi would be more tolerant than his predecessor, Hu Jintao, of mild campaigns for change.

In 2012, Mr. Xu helped promote the New Citizens Movement, an organization that drew up to 5,000 members dedicated to fighting government graft and education policies restricting the children of rural migrants from attending big city schools.

While many of the group’s activities involved informal discussions at restaurants across the country, some of its members took part in small street rallies in 2012 and early 2013 that unnerved the Communist Party leadership.

Prosecutors claimed Mr. Xu was the “ringleader” of several protests in Beijing during which participants held aloft banners denouncing corruption or demanding an end to the nation’s discriminatory education policies.

Other participants in the New Citizens Movement and similar protests also face prosecution, including two who stood trial in the two days after Mr. Xu’s trial. Four others face trial Monday in Beijing, according to Human Rights in China.

Legal experts and human rights advocates described the prosecution of Mr. Xu as deeply flawed. His lawyers were not allowed to cross-examine prosecution witnesses, whose testimony was submitted in writing only so they did not appear in court. Nor were the defense lawyers permitted to call in witnesses of their own.

Mr. Xu’s lawyers unsuccessfully challenged the legality of holding separate trials for the New Citizens Movement defendants in Beijing, a move they said prevented them from benefiting from testimony that could help in their defense. Mr. Zhang, one of his lawyers, called the trial last Wednesday “a piece of theater.”

Nicholas Bequelin, a senior researcher at Human Rights Watch in Hong Kong, said Mr. Xu’s slapdash prosecution and the sentence were designed to deter others seeking to agitate against the Communist Party’s monopoly on power.

“It sends out the message that the law is essentially a tool for the party to rule the citizenry, not for the citizenry to curtail the power of the state,” he said.