Students at one of China’s most prestigious universities on Friday denounced the government’s efforts to crush a student-led campaign for workers’ rights that has embarrassed the ruling Communist Party.

More than a dozen students from Peking University in Beijing, in a rare rebuke of authority, protested Friday on campus to draw attention to the university’s attempts to punish students for taking part in the campaign.

The students are part of a small but tenacious group of young communists using leftist ideology to shine a light on labor abuses across China and to call for better protections for the working class.

The students have put the government in an awkward position because they are invoking the teachings of Mao, Marx and Lenin, which President Xi Jinping has championed, to point to problems in Chinese society including inequality, corruption and greed.

Peking University officials moved swiftly to contain Friday’s protest, holding the students in classrooms and keeping them through the night for questioning, activists said. They were released on Saturday morning.

Videos posted online by students showed security guards shoving protesters and teachers grabbing students so they could not leave.

In one video posted on Twitter, an activist with cuts on his fingers asserted that the police had injured him. “They are trying to stop us from spreading the truth,” he said.

The stern reaction by the authorities reflects the party’s deep anxieties about the young communists and their unusual campaign.

The party has long feared student-led protests, especially since the 1989 pro-democracy movement, which had deep student involvement and was crushed in a bloody crackdown around Tiananmen Square. Party leaders may be concerned that the 30th anniversary of the massacre, coming up in June, could inspire new protests.

“They don’t want to take any chances about students organizing politically,” said Eli Friedman, a labor scholar at Cornell who in October suspended an exchange program with Renmin University in Beijing because of the recent crackdown.

The protest on Friday came after Peking University officials tried to block a Marxist student group from organizing a celebration for Mao’s 125th birthday. On Wednesday, the president of the group, Qiu Zhanxuan, was taken in for questioning by security officials, students said, and he was later removed from his post. On Friday, students held signs demanding that the university reinstate Mr. Qiu and several other members.

The university did not respond to requests for comment on Friday.

The young communists began organizing in the summer, when dozens converged on the factories of southern China to stand with workers who were seeking to form a labor union without the Communist Party’s official backing.

Throughout their campaign, the activists have steadfastly voiced support for Mr. Xi and the tenets of communism. In celebrating Mao’s birthday this week, for example, they sang socialist anthems and chanted slogans like “Long live Chairman Mao! Long live the working class!”

While the students’ leftist critique of society has gained traction among a small number of students on university campuses, their numbers have dwindled in recent weeks as the government has intensified efforts to detain leaders of the campaign.

More than two dozen activists have been detained, gone missing or placed under house arrest over the past few months. In November, a recent graduate of Peking University who took part in the campaign, Zhang Shengye, was beaten and dragged into a car on campus and driven away, according to witnesses.

Since rising to power in 2012, Mr. Xi has sought to rein in dissent, especially on university campuses. Advocates said that the crackdown on the young communists showed that the government was becoming even less tolerant of criticism.

“The message is clear,” said Patrick Poon, a researcher at Amnesty International in Hong Kong. “No one can avoid control, even the Marxists.”